Bisher keine Probleme, daher poste ich jetzt mal den MOD. Ich hoffe, ich habe nicht vergessen. Bei mir im phpBB 2.0.0 läuft es scheinbar prima.
Code: Alles auswählen
#################################################################
## Mod Title: Show unread posts (with UPITDB-MOD)
## Mod Version: 0.1 beta
## Author: "Dr. Love" <Dr.Love@nbm-clan.de>
## Description:
##
## Dieser MOD-Addon erweitert den "Unread Post Information To Database"-MOD um die
## wichtige Funktion, eine Zusammenstellung aller ungelesenen Beiträge über
## die Suchfunktion zu erstellen. Letztlich ersetzt oder ergänzt er die Funktion
## "Beiträge seit dem letzten Besuch anzeigen (x)" durch "Ungelesene Beiträge anzeigen (x)".
## Die Zahl in Klammern ist optional und erhöht die Datenbanklast der index.php.
##
## This MOD-Addon expands the "Unread Post Information To Database"-MOD with the
## important feature to crate a survey of all unread posts within the search.php.
## It replaces or completes the "Show posts since last visit (x)" with a
## "Show unread posts (x)" function. The (x) is an option which increases the
## database-load of the index.php.
##
##
## Installation Level: easy
## Installation Time: 10-15 Minutes
## Files To Edit:
## search.php
## languages/lang_xx/lang_main.php
## any template file you want the main link to be (and the corresponding php-file)
## for example overall_header.tpl
## and includes/page_header.php
## for (x)-functionality:
## index.php
##
#################################################################
##
## Author Note:
## Im Moment fehlt noch die Funktionalität, die die Zahl in den Klammern in
## Abhängigkeit von den User-Lese-Rechten berechnet. Zur Zeit zählt er grundsätzlich
## alle ungelesenen Nachrichten, auch die, die der User nicht lesen kann. Diese
## bleiben natürlich in der Zahl enthalten. Ein Workaround für diese User ist es,
## die "Alle Beiträge als gelesen markieren"-Funktion.
##
##
## There is a missing functionality, which shows the (x)-number in dependency to
## the users forum-read-rights. For now, it only counts all unread posts, also those
## which cannot be read by the user. Workaround: The user may use the "Mark all
## posts as unread"-function.
##
## the phpBB Group Reserves The Right To Remove/Edit Author Notes,
## Should It Be Warranted
##
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
#
#-----[ OPEN ]------------------------------------------
#
templates/xx/index_body.tpl
#
# or any other related file, where you want the link
#
#-----[ FIND ]------------------------------------------
#
<!-- BEGIN switch_user_logged_in -->
<a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a><br /><a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br />
<!-- END switch_user_logged_in -->
#
#-----[ REPLACE WITH ]------------------------------------------
#
#
<!-- BEGIN switch_user_logged_in -->
<a href="{U_SEARCH_UNREAD}" class="gensmall">{L_SEARCH_UNREAD}</a><br />
<a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a><br /><a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br />
<!-- END switch_user_logged_in -->
#
#-----[ CLOSE FILE ]------------------------------------------
#
#
#-----[ OPEN ]------------------------------------------
#
language/lang_xx/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
#
$lang['Search_new'] =
#
#-----[ BEFORE, ADD ]------------------------------------------
#
# for german: "Ungelesene Beiträge anzeigen"
# for english: "Show unread posts"
#
$lang['Search_unread'] = "Show unread posts";
#
#-----[ CLOSE FILE ]------------------------------------------
#
#
#-----[ OPEN ]------------------------------------------
#
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------
#
#
'L_SEARCH_NEW' => $lang['Search_new'],
#
#-----[ BEFORE, ADD ]------------------------------------------
#
#
'L_SEARCH_UNREAD' => $lang['Search_unread'],
#
#-----[ FIND ]------------------------------------------
#
#
'U_SEARCH_NEW' => append_sid('search.'.$phpEx.'?search_id=newposts'),
#
#-----[ BEFORE, ADD ]------------------------------------------
#
#
'U_SEARCH_UNREAD' => append_sid('search.'.$phpEx.'?search_id=unread'),
#
#-----[ CLOSE FILE ]------------------------------------------
#
#
#-----[ OPEN ]------------------------------------------
#
# if you don't want the (x) beside the Link on index.php, you do not need
# to edit this file.
#
#
index.php
#
#-----[ FIND ]------------------------------------------
#
#
//
// End session management
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
# if you have altered the store-time from 30 days to another value, you must
# alter the 2592000-value here, too
#
if( $userdata['session_logged_in'] )
{
$jetzt_vor_einem_monat = time() - 2592000;
$sql = "SELECT count(p.post_id)
FROM " . POSTS_TABLE . " AS p LEFT OUTER JOIN " . TOPIC_READ_TABLE . " AS r
ON ( p.topic_id = r.topic_id AND r.user_id = " . $userdata['user_id'] . ")
WHERE ( (r.user_id = " . $userdata['user_id'] . " OR r.user_id IS NULL)
AND p.post_time > " . $jetzt_vor_einem_monat . "
AND (p.post_time > r.visit_time OR p.post_edit_time > r.visit_time OR r.topic_id IS NULL) )
ORDER BY p.topic_id DESC, p.post_id DESC";
$result = $db->sql_query($sql);
if( $result )
{
$row = $db->sql_fetchrow($result);
$lang['Search_unread'] = $lang['Search_unread'] . " (" . $row[0] . ")";
}
}
#
#-----[ CLOSE FILE ]------------------------------------------
#
#
#-----[ OPEN ]------------------------------------------
#
# if you want to completely replace the "Show posts since last visit"-function,
# you just have to replace the appropriately SQL-block with the block below at _*_
#
#
search.php
#
#-----[ FIND ]------------------------------------------
#
#
if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '')
#
#-----[ REPLACE WITH ]------------------------------------------
#
#
if ( $search_id == 'newposts' || $search_id == 'unread' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '')
#
#-----[ FIND ]------------------------------------------
#
#
if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
#
if ( $search_id == 'newposts' || $search_id == 'unread' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' ) )
#
#-----[ FIND ]------------------------------------------
#
#
else if ( $search_id == 'egosearch' )
#
#-----[ BEFORE, ADD ]------------------------------------------
#
# if you have altered the store-time from 30 days to another value, you must
# alter the 2592000-value here, too
#
# _*_ needed SQL-block: $jetzt_vor_einem_monat = value; and $sql = value;
#
else if ( $search_id == 'unread' )
{
if ( $userdata['session_logged_in'] )
{
$jetzt_vor_einem_monat = time() - 2592000;
$sql = "SELECT p.post_id
FROM " . POSTS_TABLE . " AS p LEFT OUTER JOIN " . TOPIC_READ_TABLE . " AS r
ON ( p.topic_id = r.topic_id AND r.user_id = " . $userdata['user_id'] . ")
WHERE ( (r.user_id = " . $userdata['user_id'] . " OR r.user_id IS NULL)
AND p.post_time > " . $jetzt_vor_einem_monat . "
AND (p.post_time > r.visit_time OR p.post_edit_time > r.visit_time OR r.topic_id IS NULL) )";
}
else
{
header("Location: login.$phpEx?redirect=search&search_id=unread");
exit;
}
$show_results = ( $show_results == 'latest' ) ? 'latest' : 'topics';
$sort_by = 0;
$sort_dir = 'DESC';
}
#
#-----[ CLOSE FILE ]------------------------------------------
#
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Naja, die ganze Arbeit steckt in der einen SQL-Abfrage. Vielleicht hat jemand spontan ne Ahnung, wie man die Funktionen zum Auth-check benutzt. In den Code reinzulesen habe ich keine Lust mehr. Man muss quasi für jeden Beitrag in der Liste einen kurzen Check bauen, ob der User Zugriff hat. Nur dann wird der Post als ungelesen gezählt. Dazu braucht man eigentlich nur die Schnittstelle zu den Auth-check Funktionen des Forums. Der Rest ist dann Kinderkram.
Ciao, Dr. Love...