The original functions_post notifications "fix" was absolute tosh ... this is my second attempt which remembers that emails may be in different languages ... also significant altered the email class subject/charset match ... hopefully fixes the various issues seen with this.

git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3134 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-11-28 01:46:43 +00:00
parent d51c358ddb
commit 0ea2745777
3 changed files with 48 additions and 31 deletions

View file

@ -148,12 +148,24 @@ class emailer
// We now try and pull a subject from the email body ... if it exists,
// do this here because the subject may contain a variable
//
$drop_header = "";
$match = array();
preg_match("/^(Subject:(.*?)[\r\n]+?)?(Charset:(.*?)[\r\n]+?)?(.*?)$/is", $this->msg, $match);
if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
{
$this->subject = ( $this->subject != '' ) ? $this->subject : trim($match[2]);
$drop_header .= '[\r\n]*?' . $match[1];
}
$this->msg = ( isset($match[5]) ) ? trim($match[5]) : '';
$this->subject = ( $this->subject != '' ) ? $this->subject : trim($match[2]);
$this->encoding = ( trim($match[4]) != '' ) ? trim($match[4]) : $lang['ENCODING'];
if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match))
{
$this->encoding = (trim($match[2]) != '') ? trim($match[2]) : $lang['ENCODING'];
$drop_header .= '[\r\n]*?' . $match[1];
}
if ($drop_header != '')
{
$this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
}
return true;
}
@ -179,7 +191,7 @@ class emailer
// Add date and encoding type
//
$universal_extra = "MIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('D, d M Y H:i:s', time()) . " UT\n";
$this->extra_headers = $universal_extra . $this->extra_headers;
$this->extra_headers = $universal_extra . $this->extra_headers . " ---\n\n";
if ( $this->use_smtp )
{

View file

@ -567,7 +567,7 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
//
// Handle user notification on new post
//
function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$notify_user)
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;
@ -603,19 +603,19 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id
}
}
$sql = "SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title
FROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
$sql = "SELECT u.user_id, u.user_email, u.user_lang
FROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u
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 t.topic_id = tw.topic_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 = '';
$update_watched_sql = '';
$bcc_list_ary = array();
if ( $row = $db->sql_fetchrow($result) )
{
// Sixty second limit
@ -625,7 +625,7 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id
{
if ($row['user_email'] != '')
{
$bcc_list .= (($bcc_list != '') ? ', ' : '') . $row['user_email'];
$bcc_list_ary[$row['user_lang']] .= (($bcc_list_ary[$row['user_lang']] != '') ? ', ' : '') . $row['user_email'];
}
$update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id'];
}
@ -645,7 +645,7 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id
$board_config['smtp_host'] = @$ini_val('SMTP');
}
if ($bcc_list != '')
if (sizeof($bcc_list_ary))
{
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
@ -661,27 +661,32 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
$email_headers .= "Bcc: $bcc_list\n";
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($row['topic_title'])) : unprepare_message($row['topic_title']);
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);
$emailer->use_template('topic_notify', $row['user_lang']);
$emailer->email_address(' ');
$emailer->set_subject();
$emailer->extra_headers($email_headers);
while (list($user_lang, $bcc_list) = each($bcc_list_ary))
{
$emailer->use_template('topic_notify', $user_lang);
$emailer->email_address(' ');
$emailer->set_subject();
$emailer->extra_headers($email_headers . "Bcc: $bcc_list\n");
$emailer->assign_vars(array(
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
'USERNAME' => $row['username'],
'SITENAME' => $board_config['sitename'],
'TOPIC_TITLE' => $topic_title,
// This is a nasty kludge to remove the username var ... till (if?)
// translators update their templates
$emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
'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->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'],
'TOPIC_TITLE' => $topic_title,
$emailer->send();
$emailer->reset();
'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();
}
}
}
$db->sql_freeresult($result);

View file

@ -209,7 +209,7 @@ switch ( $mode )
message_die(GENERAL_MESSAGE, $lang['No_topic_id']);
}
$sql = "SELECT f.*, t.topic_status
$sql = "SELECT f.*, t.topic_status, t.topic_title
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t
WHERE t.topic_id = $topic_id
AND f.forum_id = t.forum_id";
@ -583,8 +583,8 @@ else if ( $submit || $confirm )
}
if ($error_msg == '' && $mode != 'poll_delete')
{
user_notification($mode, $post_data, $forum_id, $topic_id, $post_id, $notify_user);
{echo "HERE --> " . $post_info['topic_title'] . " \n\n";
user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
}
if ( $mode == 'newtopic' || $mode == 'reply' )