So, nachdem seit dem letzten Mod-Update rund 1 1/2 Jahre vergangen sind und immer noch laufend Anfragen hereinkommen, habe ich mir selber in den Hintern getreten und den Mod an phpBB 2.0.6 angepasst. Der alte Code in der user_notification Funktion war im Prinzip komplett unbrauchbar, weil hier glaub ich mit phpBB 2.0.5 oder so alles komplett umgestellt wurde (deshalb sind auch bei der Implementation des Mods auf neueren Boards so viele Fehler aufgetreten).
Jetzt ist das Ganze sauber neu geschrieben und getestet, es sollte soweit recht gut funktionieren. Ich habe es heute mit einem phpBB 2.0.6c implementiert und intensiv ausprobiert. Über Feedback bezüglich Funktionalität wäre ich auf jeden Fall sehr erfreut

Ihr könnt den Mod hier finden: http://davilsphpbb.sourceforge.net/notification_mod/
Sorry an alle, die ewig auf diesen Moment warten mussten, aber ich hatte einfach weder Zeit noch Lust dazu, und es war auch wirklich nicht einfach.
Hier noch das komplette Listing für diejenigen, die es ganz eilig haben

Code: Alles auswählen
#################################################################
## Mod Title: Forum notification mod
## Mod Version: 1.4
## Date: 2004-02-22
## Author: David Herrmann < david.herrmann@gmx.net >
## Description: adds forum notification functionality to phpBB 2.0.6c,
## also adds some enhancements to the email bodies
##
## Installation Level: intermediate
## Installation Time: 20 Minutes
## Files To Edit:
## posting.php
## viewforum.php
## admin/admin_forums.php
## includes/constants.php
## includes/functions_post.php
## language/lang_english/lang_main.php
## language/lang_english/lang_admin.php
## language/lang_english/email/topic_notify.tpl
## templates/subSilver/viewforum_body.tpl
## templates/subSilver/admin/forum_edit_body.tpl
##
## language/lang_german/lang_main.php
## language/lang_german/lang_admin.php
## language/lang_german/email/topic_notify.tpl
##
## Files to Create:
## language/lang_english/email/newtopic_notify.tpl
## language/lang_english/email/forum_notify.tpl
##
## language/lang_german/email/newtopic_notify.tpl
## language/lang_german/email/forum_notify.tpl
##
## Included Files:
## posting.php
## viewforum.php
## admin/admin_forums.php
## includes/constants.php
## includes/functions_post.php
## language/lang_english/lang_main.php
## language/lang_english/lang_admin.php
## language/lang_english/email/topic_notify.tpl
## language/lang_english/email/newtopic_notify.tpl
## language/lang_english/email/forum_notify.tpl
## language/lang_german/lang_main.php
## language/lang_german/lang_admin.php
## language/lang_german/email/topic_notify.tpl
## language/lang_german/email/newtopic_notify.tpl
## language/lang_german/email/forum_notify.tpl
## templates/subSilver/viewforum_body.tpl
## templates/subSilver/admin/forum_edit_body.tpl
##
#################################################################
##
## Author Note:
##
## This mod adds a "watch this forum" link to the viewforum page, similar to the
## "watch this topic" link on viewtopic. Further on, this mod changes the structure
## of email bodies, now including the post text, the name of the poster etc. in the
## email text.
## There are different email texts for watched topic (reply), watched forum (newtopic) and
## watched forum (reply).
## The texts are available both in English and German.
##
## Security should be ok, you are not able to receive a notification email if the forum is private
## and you are not allowed to read!
##
## Do not forget to run the following commands on your sql database (replace phpbb2_ with your db prefix):
##
##CREATE TABLE phpbb2_forums_watch (
## forum_id smallint(5) unsigned NOT NULL default '0',
## user_id mediumint(8) NOT NULL default '0',
## notify_status tinyint(1) NOT NULL default '0',
## KEY forum_id (forum_id),
## KEY user_id (user_id),
## KEY notify_status (notify_status)
## )
##
##ALTER TABLE phpbb2_forums
## ADD forum_notify TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL
## AFTER forum_last_post_id
##
## the description is for subsilver theme users, it should work with every theme
## if you are using the files from the package you only have to run the sql command
##
## this mod was tested on phpBB 2.0.6c
##
## Should be no problem for any user who knows what they are doing ;-)
##
#################################################################
##
## New in 1.4:
##
## Updated mod for phpBB 2.0.6c (should also do with 2.0.5, but untested)
##
#################################################################
##
## New in 1.2:
##
## Fixed the url bug in the email text. users of 1.1 can replace the user_notification
## function in the incldues/functions_post.php file with the new one and it should work.
##
#################################################################
##
## New in 1.1:
##
## Now there's a checkbox in the "edit forum" admin panel where you can turn the
## notification on or off for every forum. for example, a test forum won't need
## notification ever and any user doing it would only cause useless traffic.
##
#################################################################
##
## users of version 1.0 of this mod should just use the files in the package to
## overwrite the old ones and run the second sql command. there were slight changes
## in nearly every file!
## of course you can also run a diff to the 1.0 description and only update the changed areas ;-)
##
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/posting.php
#
#-----[ FIND ]------------------------------------------
#
user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
#
#-----[ REPLACE WITH ]------------------------------------------
#
// forum notification mod
$post_data['subject'] = $subject;
$post_data['username'] = ( $userdata['user_id'] == ANONYMOUS ) ? $username : $userdata['username'];
$post_data['message'] = $message;
if ( $post_data['first_post'] )
{
// fetch topic title
$sql = "SELECT topic_title, topic_id
FROM " . TOPICS_TABLE . "
WHERE topic_id = $topic_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic title for notification', '', __LINE__, __FILE__, $sql);
}
if ( $topic_info = $db->sql_fetchrow($result) )
{
user_notification('newtopic', $post_data, $topic_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
}
}
else
{
user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
}
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/viewforum.php
#
#-----[ FIND ]------------------------------------------
#
$l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
$forum_moderators = ( count($moderators) ) ? implode(", ", $moderators) : $lang['None'];
unset($moderators);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Is user watching this forum?
//
if( $userdata['session_logged_in'] )
{
( $forum_row['forum_notify'] == '1' ) ? $can_watch_forum = TRUE : $can_watch_forum = FALSE;
$sql = "SELECT notify_status
FROM " . FORUMS_WATCH_TABLE . "
WHERE forum_id = $forum_id
AND user_id = " . $userdata['user_id'];
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't obtain forum watch information", "", __LINE__, __FILE__, $sql);
}
if( $row = $db->sql_fetchrow($result) )
{
if( isset($HTTP_GET_VARS['unwatch']) )
{
if( $HTTP_GET_VARS['unwatch'] == "forum" )
{
$is_watching_forum = 0;
$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : "";
$sql = "DELETE $sql_priority FROM " . FORUMS_WATCH_TABLE . "
WHERE forum_id = $forum_id
AND user_id = " . $userdata['user_id'];
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete forum watch information", "", __LINE__, __FILE__, $sql);
}
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&start=$start") . '">')
);
$message = $lang['No_longer_watching_forum'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&start=$start") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else
{
$is_watching_forum = TRUE;
if( $row['notify_status'] )
{
$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : "";
$sql = "UPDATE $sql_priority " . FORUMS_WATCH_TABLE . "
SET notify_status = 0
WHERE forum_id = $forum_id
AND user_id = " . $userdata['user_id'];
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't update forum watch information", "", __LINE__, __FILE__, $sql);
}
}
}
}
else
{
if( isset($HTTP_GET_VARS['watch']) )
{
if( $HTTP_GET_VARS['watch'] == "forum" )
{
$is_watching_forum = TRUE;
$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : "";
$sql = "INSERT $sql_priority INTO " . FORUMS_WATCH_TABLE . " (user_id, forum_id, notify_status)
VALUES (" . $userdata['user_id'] . ", $forum_id, 0)";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't insert forum watch information", "", __LINE__, __FILE__, $sql);
}
}
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&start=$start") . '">')
);
$message = $lang['You_are_watching_forum'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&start=$start") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else
{
$is_watching_forum = 0;
}
}
}
else
{
if( isset($HTTP_GET_VARS['unwatch']) )
{
if( $HTTP_GET_VARS['unwatch'] == "forum" )
{
header("Location: " . append_sid("login.$phpEx?redirect=viewforum.$phpEx&" . POST_FORUM_URL . "=$forum_id&unwatch=forum", true));
}
}
else
{
$can_watch_forum = 0;
$is_watching_forum = 0;
}
}
#
#-----[ FIND ]------------------------------------------
#
//
// Mozilla navigation bar
//
$nav_links['up'] = array(
'url' => append_sid("index.".$phpEx),
'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//
// Forum watch information
//
$s_watching_forum = "";
if( $can_watch_forum )
{
if( $is_watching_forum )
{
$s_watching_forum = '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&unwatch=forum&start=$start") . '">' . $lang['Stop_watching_forum'] . '</a>';
$s_watching_forum_img = ( isset($images['Forum_un_watch']) ) ? '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&unwatch=forum&start=$start") . '"><img src="' . $images['Forum_un_watch'] . '" alt="' . $lang['Stop_watching_forum'] . '" title="' . $lang['Stop_watching_forum'] . '" border="0"></a>' : '';
}
else
{
$s_watching_forum = '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&watch=forum&start=$start") . '">' . $lang['Start_watching_forum'] . '</a>';
$s_watching_forum_img = ( isset($images['Forum_watch']) ) ? '<a href="' . append_sid("viewforum.$phpEx?" . POST_TOPIC_URL . "=$forum_id&watch=forum&start=$start") . '"><img src="' . $images['Forum_watch'] . '" alt="' . $lang['Stop_watching_forum'] . '" title="' . $lang['Start_watching_forum'] . '" border="0"></a>' : '';
}
}
#
#-----[ FIND ]------------------------------------------
#
'S_AUTH_LIST' => $s_auth_can,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'S_WATCH_FORUM' => $s_watching_forum,
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
define('FORUMS_TABLE', $table_prefix.'forums');
#
#-----[ AFTER, ADD ]------------------------------------------
#
define('FORUMS_WATCH_TABLE', $table_prefix.'forums_watch');
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/includes/functions_post.php
#
#-----[ FIND ]------------------------------------------
#
//
// Handle user notification on new post
//
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
... // function content ...
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Handle user notification on new post (including forum notification)
//
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
global $userdata, $user_ip;
$current_time = time();
if ($mode == 'delete')
{
$delete_sql = (!$post_data['first_post'] && !$post_data['last_post']) ? " AND user_id = " . $userdata['user_id'] : '';
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id" . $delete_sql;
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not change topic notify data', '', __LINE__, __FILE__, $sql);
}
}
else
{
if ($mode == 'reply')
{
$sql = "SELECT ban_userid
FROM " . BANLIST_TABLE;
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql);
}
$user_id_sql = '';
while ($row = $db->sql_fetchrow($result))
{
if (isset($row['ban_userid']) && !empty($row['ban_userid']))
{
$user_id_sql .= ', ' . $row['ban_userid'];
}
}
$sql = "SELECT u.user_id, u.user_email, u.user_lang, u.username, f.forum_name
FROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u, " . FORUMS_TABLE . " f
WHERE tw.topic_id = $topic_id
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")
AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "
AND f.forum_id = $forum_id
AND u.user_id = tw.user_id";
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $sql);
}
$update_watched_sql = '';
$bcc_list_ary = array();
$users_ary = array();
if ($row = $db->sql_fetchrow($result))
{
// Sixty second limit
@set_time_limit(60);
do
{
if ($row['user_email'] != '')
{
$bcc_list_ary[$row['user_lang']][] = $row['user_email'];
$users_ary[$row['user_email']] = $row['username'];
}
$forum_name = $row['forum_name'];
$update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id'];
}
while ($row = $db->sql_fetchrow($result));
//
// Let's do some checking to make sure that mass mail functions
// are working in win32 versions of php.
//
if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery'])
{
$ini_val = (@phpversion() >= '4.0.0') ? 'ini_get' : 'get_cfg_var';
// We are running on windows, force delivery to use our smtp functions
// since php's are broken by default
$board_config['smtp_delivery'] = 1;
$board_config['smtp_host'] = @$ini_val('SMTP');
}
if (sizeof($bcc_list_ary))
{
include_once($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);
$post_text = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($post_data['message'])) : unprepare_message($post_data['message']);
@reset($bcc_list_ary);
while (list($user_lang, $bcc_list) = each($bcc_list_ary))
{
$emailer->use_template('topic_notify', $user_lang);
for ($i = 0; $i < count($bcc_list); $i++)
{
$emailer->bcc($bcc_list[$i]);
}
// The Topic_reply_notification lang string below will be used
// if for some reason the mail template subject cannot be read
// ... note it will not necessarily be in the posters own language!
$emailer->set_subject($lang['Topic_reply_notification']);
// This is a nasty kludge to remove the username var ... till (if?)
// translators update their templates
// $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
$emailer->assign_vars(array(
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
'SITENAME' => $board_config['sitename'],
'USERNAME' => $users_ary[$bcc_list['0']],
'TOPIC_TITLE' => $topic_title,
'POST_TEXT' => $post_text,
'POSTERNAME' => $post_data['username'],
'FORUM_NAME' => $forum_name,
'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "=$topic_id&unwatch=topic")
);
$emailer->send();
$emailer->reset();
}
}
}
$already_mailed = ( trim($update_watched_sql) == '' ) ? "" : "$update_watched_sql, ";
$db->sql_freeresult($result);
// start of reply forum notification
$sql = "SELECT u.user_id, u.user_email, u.user_lang, f.forum_name
FROM " . USERS_TABLE . " u, " . FORUMS_WATCH_TABLE . " fw, " . FORUMS_TABLE . " f
WHERE fw.forum_id = $forum_id
AND fw.user_id NOT IN (" . $already_mailed . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . " )
AND f.forum_id = $forum_id
AND f.forum_notify = '1'
AND u.user_id = fw.user_id";
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $sql);
}
$bcc_list_ary = array();
$users_ary = array();
if ($row = $db->sql_fetchrow($result))
{
// Sixty second limit
@set_time_limit(60);
do
{
if ($row['user_email'] != '')
{
$bcc_list_ary[$row['user_lang']][] = $row['user_email'];
$users_ary[$row['user_email']] = $row['username'];
}
$forum_name = $row['forum_name'];
}
while ($row = $db->sql_fetchrow($result));
//
// Let's do some checking to make sure that mass mail functions
// are working in win32 versions of php.
//
if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery'])
{
$ini_val = (@phpversion() >= '4.0.0') ? 'ini_get' : 'get_cfg_var';
// We are running on windows, force delivery to use our smtp functions
// since php's are broken by default
$board_config['smtp_delivery'] = 1;
$board_config['smtp_host'] = @$ini_val('SMTP');
}
if (sizeof($bcc_list_ary))
{
include_once($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name_forum = ($script_name != '') ? $script_name . '/viewforum.'.$phpEx : 'viewforum.'.$phpEx;
$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);
$post_text = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($post_data['message'])) : unprepare_message($post_data['message']);
$temp_is_auth = array();
@reset($bcc_list_ary);
while (list($user_lang, $bcc_list) = each($bcc_list_ary))
{
$temp_userdata = get_userdata($row['user_id']);
$temp_is_auth = auth(AUTH_ALL, $forum_id, $temp_userdata, -1);
// another security check (i.e. the forum might have become private and
// there are still users who have notification activated)
if( $temp_is_auth['auth_read'] && $temp_is_auth['auth_view'] )
{
$emailer->use_template('forum_notify', $user_lang);
for ($i = 0; $i < count($bcc_list); $i++)
{
$emailer->bcc($bcc_list[$i]);
}
// The Topic_reply_notification lang string below will be used
// if for some reason the mail template subject cannot be read
// ... note it will not necessarily be in the posters own language!
$emailer->set_subject($lang['Topic_reply_notification']);
// This is a nasty kludge to remove the username var ... till (if?)
// translators update their templates
// $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
$emailer->assign_vars(array(
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
'SITENAME' => $board_config['sitename'],
'USERNAME' => $users_ary[$bcc_list['0']],
'TOPIC_TITLE' => $topic_title,
'POST_TEXT' => $post_text,
'POSTERNAME' => $post_data['username'],
'FORUM_NAME' => $forum_name,
'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
'U_STOP_WATCHING_FORUM' => $server_protocol . $server_name . $server_port . $script_name_forum . "?" . POST_FORUM_URL . "=$forum_id&unwatch=forum")
);
$emailer->send();
$emailer->reset();
}
}
}
}
// end of forum notification on reply
$db->sql_freeresult($result);
if ($update_watched_sql != '')
{
$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
SET notify_status = " . TOPIC_WATCH_NOTIFIED . "
WHERE topic_id = $topic_id
AND user_id IN ($update_watched_sql)";
$db->sql_query($sql);
}
}
//
// code for newtopic forum notification
//
if ($mode == 'newtopic')
{
$sql = "SELECT ban_userid
FROM " . BANLIST_TABLE;
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql);
}
$user_id_sql = '';
while ($row = $db->sql_fetchrow($result))
{
if (isset($row['ban_userid']) && !empty($row['ban_userid']))
{
$user_id_sql .= ', ' . $row['ban_userid'];
}
}
$sql = "SELECT u.user_id, u.username, u.user_email, u.user_lang, f.forum_name
FROM " . FORUMS_WATCH_TABLE . " fw, " . USERS_TABLE . " u, " . FORUMS_TABLE . " f
WHERE fw.forum_id = $forum_id
AND fw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")
AND f.forum_id = $forum_id
AND f.forum_notify = '1'
AND u.user_id = fw.user_id";
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not obtain list of forum watchers', '', __LINE__, __FILE__, $sql);
}
$bcc_list_ary = array();
$users_ary = array();
if ($row = $db->sql_fetchrow($result))
{
// Sixty second limit
@set_time_limit(60);
unset($forum_name);
do
{
if ($row['user_email'] != '')
{
$bcc_list_ary[$row['user_lang']][] = $row['user_email'];
$users_ary[$row['user_email']] = $row['username'];
}
$forum_name = $row['forum_name'];
}
while ($row = $db->sql_fetchrow($result));
//
// Let's do some checking to make sure that mass mail functions
// are working in win32 versions of php.
//
if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery'])
{
$ini_val = (@phpversion() >= '4.0.0') ? 'ini_get' : 'get_cfg_var';
// We are running on windows, force delivery to use our smtp functions
// since php's are broken by default
$board_config['smtp_delivery'] = 1;
$board_config['smtp_host'] = @$ini_val('SMTP');
}
if (sizeof($bcc_list_ary))
{
include_once($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name_forum = ($script_name != '') ? $script_name . '/viewforum.'.$phpEx : 'viewforum.'.$phpEx;
$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);
$post_text = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($post_data['message'])) : unprepare_message($post_data['message']);
$temp_is_auth = array();
@reset($bcc_list_ary);
while (list($user_lang, $bcc_list) = each($bcc_list_ary))
{
$temp_userdata = get_userdata($row['user_id']);
$temp_is_auth = auth(AUTH_ALL, $forum_id, $temp_userdata, -1);
// another security check (i.e. the forum might have become private and
// there are still users who have notification activated)
if( $temp_is_auth['auth_read'] && $temp_is_auth['auth_view'] )
{
$emailer->use_template('newtopic_notify', $user_lang);
for ($i = 0; $i < count($bcc_list); $i++)
{
$emailer->bcc($bcc_list[$i]);
}
// The Topic_reply_notification lang string below will be used
// if for some reason the mail template subject cannot be read
// ... note it will not necessarily be in the posters own language!
$emailer->set_subject($lang['Topic_reply_notification']);
// This is a nasty kludge to remove the username var ... till (if?)
// translators update their templates
// $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
$emailer->assign_vars(array(
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
'SITENAME' => $board_config['sitename'],
'USERNAME' => $users_ary[$bcc_list['0']],
'TOPIC_TITLE' => $topic_title,
'POST_TEXT' => $post_text,
'POSTERNAME' => $post_data['username'],
'FORUM_NAME' => $forum_name,
'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
'U_STOP_WATCHING_FORUM' => $server_protocol . $server_name . $server_port . $script_name_forum . "?" . POST_FORUM_URL . "=$forum_id&unwatch=forum")
);
$emailer->send();
$emailer->reset();
}
}
}
}
$db->sql_freeresult($result);
}
$sql = "SELECT topic_id
FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
if (!$notify_user && !empty($row['topic_id']))
{
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id = " . $userdata['user_id'];
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not delete topic watch information', '', __LINE__, __FILE__, $sql);
}
}
else if ($notify_user && empty($row['topic_id']))
{
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not insert topic watch information', '', __LINE__, __FILE__, $sql);
}
}
}
}
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------
#
$cat_id = $row['cat_id'];
$forumname = $row['forum_name'];
$forumdesc = $row['forum_desc'];
$forumstatus = $row['forum_status'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
$forum_notify = $row['forum_notify'];
#
#-----[ FIND ]------------------------------------------
#
else
{
$l_title = $lang['Create_forum'];
$newmode = 'createforum';
$buttonvalue = $lang['Create_forum'];
$forumdesc = '';
$forumstatus = FORUM_UNLOCKED;
$forum_id = '';
$prune_enabled = '';
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
else
{
$l_title = $lang['Create_forum'];
$newmode = 'createforum';
$buttonvalue = $lang['Create_forum'];
$forumdesc = '';
$forumstatus = FORUM_UNLOCKED;
$forum_id = '';
$prune_enabled = '';
$forum_notify = '1';
}
( $forum_notify == '1' ) ? $notify_enabled = "selected=\"selected\"" : $notify_disabled = "selected=\"selected\"";
$notifylist = "<option value=\"1\" $notify_enabled>" . $lang['Forum_notify_enabled'] . "</option>\n";
$notifylist .= "<option value=\"0\" $notify_disabled>" . $lang['Forum_notify_disabled'] . "</option>\n";
#
#-----[ FIND ]------------------------------------------
#
'S_PRUNE_ENABLED' => $prune_enabled,
#
#-----[ AFTER, ADD ]------------------------------------------
#
'S_NOTIFY_ENABLED' => $notifylist,
#
#-----[ FIND ]------------------------------------------
#
'L_FORUM_STATUS' => $lang['Forum_status'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_FORUM_NOTIFY' => $lang['Forum_notify'],
#
#-----[ FIND ]------------------------------------------
#
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
#
#-----[ REPLACE WITH ]------------------------------------------
#
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, forum_notify, prune_enable" . $field_sql . ")
VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['notify_enable']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
#
#-----[ FIND ]------------------------------------------
#
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
#
#-----[ REPLACE WITH ]------------------------------------------
#
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", forum_notify = " . intval($HTTP_POST_VARS['notify_enable']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
#
#-----[ FIND ]------------------------------------------
#
if( $db->sql_numrows($result) > 0 )
{
$sql = "UPDATE " . PRUNE_TABLE . "
SET prune_days = " . intval($HTTP_POST_VARS['prune_days']) . ", prune_freq = " . intval($HTTP_POST_VARS['prune_freq']) . "
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
}
else
{
$sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
}
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql);
}
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
if( $HTTP_POST_VARS['notify_enable'] != '1' )
{
// delete all notifications for that forum
$sql = "DELETE
FROM " . FORUMS_WATCH_TABLE . "
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't Update Forum Notify Information","",__LINE__, __FILE__, $sql);
}
}
#
#-----[ FIND ]------------------------------------------
#
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
WHERE forum_id = $from_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete forum", "", __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . PRUNE_TABLE . "
WHERE forum_id = $from_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete forum prune information!", "", __LINE__, __FILE__, $sql);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
// delete all notifications for that forum
$sql = "DELETE FROM " . FORUMS_WATCH_TABLE . "
WHERE forum_id = $from_id";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't Delete Forum Notify Information","",__LINE__, __FILE__, $sql);
}
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['You_are_watching'] = 'You are now watching this topic';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Stop_watching_forum'] = 'Stop watching this forum';
$lang['Start_watching_forum'] = 'Watch this forum for posts';
$lang['No_longer_watching_forum'] = 'You are no longer watching this forum.';
$lang['You_are_watching_forum'] = 'You are now watching this forum.';
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Forum_status'] = 'Forum status';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Forum_notify'] = 'Allow forum notification';
$lang['Forum_notify_enabled'] = 'Allow';
$lang['Forum_notify_disabled'] = 'Do not allow';
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/email/topic_notify.tpl
#
#-----[ REPLACE WITH ]------------------------------------------
#
Subject: Topic Reply Notification for "{TOPIC_TITLE}" in forum "{FORUM_NAME}"
Charset: iso-8859-1
Hello {USERNAME}!
{POSTERNAME} has posted a new reply to "{TOPIC_TITLE}" in the "{FORUM_NAME}" forum at {SITENAME}. You can use the following link to view the replies made:
{U_TOPIC}
-----------------------------------------------
Posted text:
{POST_TEXT}
-----------------------------------------------
You are receiving this email because you are watching the topic, "{TOPIC_TITLE}" at {SITENAME}. If you no longer wish to watch this topic you can either click the "Stop watching this topic link" found at the bottom of the topic above, or by clicking the following link:
{U_STOP_WATCHING_TOPIC}
{EMAIL_SIG}
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right">{JUMPBOX}</td>
</tr>
</table>
#
#-----[ REPLACE WITH ]------------------------------------------
#
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><span class="gensmall">{S_WATCH_FORUM}</span></td>
</tr>
<tr>
<td align="right">{JUMPBOX}</td>
</tr>
</table>
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/templates/subSilver/admin/forum_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">{L_FORUM_STATUS}</td>
<td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1">{L_FORUM_NOTIFY}</td>
<td class="row2"><select name="notify_enable">{S_NOTIFY_ENABLED}</select></td>
</tr>
#
#-----[ CREATE ]------------------------------------------
#
phpBB2/language/lang_english/email/newtopic_notify.tpl
#
#-----[ AFTER, ADD ]------------------------------------------
#
Subject: New Topic Notification for forum "{FORUM_NAME}" - {TOPIC_TITLE}
Charset: iso-8859-1
Hello {USERNAME}!
{POSTERNAME} has posted a new topic called "{TOPIC_TITLE}" in the "{FORUM_NAME}" forum at {SITENAME}. You can use the following link to view the topic:
{U_TOPIC}
-----------------------------------------------
Posted text:
{POST_TEXT}
-----------------------------------------------
You are receiving this email because you are watching the forum, "{FORUM_NAME}" at {SITENAME}. If you no longer wish to watch this forum you can either click the "Stop watching this forum link" found at the bottom of the "{FORUM_NAME}" forum, or by clicking the following link:
{U_STOP_WATCHING_FORUM}
{EMAIL_SIG}
#
#-----[ CREATE ]------------------------------------------
#
phpBB2/language/lang_english/email/forum_notify.tpl
#
#-----[ AFTER, ADD ]------------------------------------------
#
Subject: Topic Reply Notification for forum "{FORUM_NAME}" - {TOPIC_TITLE}
Charset: iso-8859-1
Hello {USERNAME}!
{POSTERNAME} has posted a new reply to "{TOPIC_TITLE}" in the "{FORUM_NAME}" forum at {SITENAME}. You can use the following link to view the replies made:
{U_TOPIC}
-----------------------------------------------
Posted text:
{POST_TEXT}
-----------------------------------------------
You are receiving this email because you are watching the forum, "{FORUM_NAME}" at {SITENAME}. If you no longer wish to watch this forum you can either click the "Stop watching this forum link" found at the bottom of the "{FORUM_NAME}" forum, or by clicking the following link:
{U_STOP_WATCHING_FORUM}
{EMAIL_SIG}
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/language/lang_german/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['You_are_watching'] = 'Du beobachtest nun das Thema.';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Stop_watching_forum'] = 'Bei Beiträgen in diesem Forum nicht mehr benachrichtigen';
$lang['Start_watching_forum'] = 'Bei Beiträgen in diesem Forum benachrichtigen';
$lang['No_longer_watching_forum'] = 'Das Forum wird nicht mehr von Dir beobachtet.';
$lang['You_are_watching_forum'] = 'Du beobachtest nun das Forum.';
#
#-----[ OPEN ]------------------------------------------
#
phpBB2/language/lang_german/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Forum_status'] = 'Forumsstatus';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Forum_notify'] = 'Abonnieren erlauben';
$lang['Forum_notify_enabled'] = 'Erlauben';
$lang['Forum_notify_disabled'] = 'Nicht erlauben';
#
#-----[ OPEN ]------------------------------------------
#
language/lang_german/email/topic_notify.tpl
#
#-----[ REPLACE WITH ]------------------------------------------
#
Subject: Benachrichtigen bei Antworten zum Thema "{TOPIC_TITLE}" im Forum "{FORUM_NAME}"
Charset: iso-8859-1
Hallo {USERNAME}!
{POSTERNAME} hat eine neue Antwort zum Thema "{TOPIC_TITLE}" im Forum "{FORUM_NAME}" auf {SITENAME} erstellt. Du kannst den folgenden Link benutzen, um direkt zum Thema zu gelanden:
{U_TOPIC}
-----------------------------------------------
Text des Beitrags:
{POST_TEXT}
-----------------------------------------------
Du erhältst diese E-Mail, weil du über Antworten im Thema "{TOPIC_TITLE}" auf {SITENAME} benachrichtigt werden wolltest. Bis du den Link besucht hast, werden keine weiteren Benachrichtigungen über dieses Topic an dich gesendet. Wenn du gar nicht mehr über Antworten in diesem Thema benachrichtigt werden möchtest, dann klick den folgenden Link an:
{U_STOP_WATCHING_TOPIC}
{EMAIL_SIG}
#
#-----[ CREATE ]------------------------------------------
#
phpBB2/language/lang_german/email/newtopic_notify.tpl
#
#-----[ AFTER, ADD ]------------------------------------------
#
Subject: Benachrichtigen bei neuen Beiträgen im Forum "{FORUM_NAME}" - {TOPIC_TITLE}
Charset: iso-8859-1
Hallo {USERNAME}!
{POSTERNAME} hat einen neues Thema mit der Bezeichnung "{TOPIC_TITLE}" im Forum "{FORUM_NAME}" erstellt. Du kannst den folgenden Link benutzen, um direkt zum Thema zu gelanden:
{U_TOPIC}
-----------------------------------------------
Text des Beitrags:
{POST_TEXT}
-----------------------------------------------
Du erhältst diese E-Mail, weil du über neue Beiträge im Forum "{FORUM_NAME}" auf {SITENAME} benachrichtigt werden wolltest. Um die Benachrichtigung zu deaktivieren, benutze den folgenden Link:
{U_STOP_WATCHING_FORUM}
{EMAIL_SIG}
#
#-----[ CREATE ]------------------------------------------
#
phpBB2/language/lang_german/email/forum_notify.tpl
#
#-----[ AFTER, ADD ]------------------------------------------
#
Subject: Benachrichtigen bei neuen Beiträgen im Forum "{FORUM_NAME}" - {TOPIC_TITLE}
Charset: iso-8859-1
Hallo {USERNAME}!
{POSTERNAME} hat eine neue Antwort zum Thema "{TOPIC_TITLE}" im Forum "{FORUM_NAME}" erstellt. Du kannst den folgenden Link benutzen, um direkt zum Thema zu gelanden:
{U_TOPIC}
-----------------------------------------------
Text des Beitrags:
{POST_TEXT}
-----------------------------------------------
Du erhältst diese E-Mail, weil du über neue Beiträge im Forum "{FORUM_NAME}" auf {SITENAME} benachrichtigt werden wolltest. Um die Benachrichtigung zu deaktivieren, benutze den folgenden Link:
{U_STOP_WATCHING_FORUM}
{EMAIL_SIG}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
davil