mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
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:
parent
d51c358ddb
commit
0ea2745777
3 changed files with 48 additions and 31 deletions
|
@ -148,12 +148,24 @@ class emailer
|
||||||
// We now try and pull a subject from the email body ... if it exists,
|
// We now try and pull a subject from the email body ... if it exists,
|
||||||
// do this here because the subject may contain a variable
|
// do this here because the subject may contain a variable
|
||||||
//
|
//
|
||||||
|
$drop_header = "";
|
||||||
$match = array();
|
$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]) : '';
|
if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match))
|
||||||
$this->subject = ( $this->subject != '' ) ? $this->subject : trim($match[2]);
|
{
|
||||||
$this->encoding = ( trim($match[4]) != '' ) ? trim($match[4]) : $lang['ENCODING'];
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +191,7 @@ class emailer
|
||||||
// Add date and encoding type
|
// 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";
|
$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 )
|
if ( $this->use_smtp )
|
||||||
{
|
{
|
||||||
|
|
|
@ -567,7 +567,7 @@ function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
||||||
//
|
//
|
||||||
// Handle user notification on new post
|
// 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 $board_config, $lang, $db, $phpbb_root_path, $phpEx;
|
||||||
global $userdata, $user_ip;
|
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
|
$sql = "SELECT u.user_id, u.user_email, u.user_lang
|
||||||
FROM " . TOPICS_WATCH_TABLE . " tw, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
|
FROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u
|
||||||
WHERE tw.topic_id = $topic_id
|
WHERE tw.topic_id = $topic_id
|
||||||
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . " )
|
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . " )
|
||||||
AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "
|
AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "
|
||||||
AND t.topic_id = tw.topic_id
|
|
||||||
AND u.user_id = tw.user_id";
|
AND u.user_id = tw.user_id";
|
||||||
if ( !($result = $db->sql_query($sql)) )
|
if ( !($result = $db->sql_query($sql)) )
|
||||||
{
|
{
|
||||||
message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $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) )
|
if ( $row = $db->sql_fetchrow($result) )
|
||||||
{
|
{
|
||||||
// Sixty second limit
|
// Sixty second limit
|
||||||
|
@ -625,7 +625,7 @@ function user_notification($mode, &$post_data, &$forum_id, &$topic_id, &$post_id
|
||||||
{
|
{
|
||||||
if ($row['user_email'] != '')
|
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'];
|
$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');
|
$board_config['smtp_host'] = @$ini_val('SMTP');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bcc_list != '')
|
if (sizeof($bcc_list_ary))
|
||||||
{
|
{
|
||||||
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
|
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
|
||||||
$emailer = new emailer($board_config['smtp_delivery']);
|
$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']) . '/' : '/';
|
$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 = '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']);
|
while (list($user_lang, $bcc_list) = each($bcc_list_ary))
|
||||||
$emailer->email_address(' ');
|
{
|
||||||
$emailer->set_subject();
|
$emailer->use_template('topic_notify', $user_lang);
|
||||||
$emailer->extra_headers($email_headers);
|
$emailer->email_address(' ');
|
||||||
|
$emailer->set_subject();
|
||||||
|
$emailer->extra_headers($email_headers . "Bcc: $bcc_list\n");
|
||||||
|
|
||||||
$emailer->assign_vars(array(
|
// This is a nasty kludge to remove the username var ... till (if?)
|
||||||
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
|
// translators update their templates
|
||||||
'USERNAME' => $row['username'],
|
$emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
|
||||||
'SITENAME' => $board_config['sitename'],
|
|
||||||
'TOPIC_TITLE' => $topic_title,
|
|
||||||
|
|
||||||
'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
|
$emailer->assign_vars(array(
|
||||||
'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "=$topic_id&unwatch=topic")
|
'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();
|
'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
|
||||||
$emailer->reset();
|
'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);
|
$db->sql_freeresult($result);
|
||||||
|
|
|
@ -209,7 +209,7 @@ switch ( $mode )
|
||||||
message_die(GENERAL_MESSAGE, $lang['No_topic_id']);
|
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
|
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t
|
||||||
WHERE t.topic_id = $topic_id
|
WHERE t.topic_id = $topic_id
|
||||||
AND f.forum_id = t.forum_id";
|
AND f.forum_id = t.forum_id";
|
||||||
|
@ -583,8 +583,8 @@ else if ( $submit || $confirm )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error_msg == '' && $mode != 'poll_delete')
|
if ($error_msg == '' && $mode != 'poll_delete')
|
||||||
{
|
{echo "HERE --> " . $post_info['topic_title'] . " \n\n";
|
||||||
user_notification($mode, $post_data, $forum_id, $topic_id, $post_id, $notify_user);
|
user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $mode == 'newtopic' || $mode == 'reply' )
|
if ( $mode == 'newtopic' || $mode == 'reply' )
|
||||||
|
|
Loading…
Add table
Reference in a new issue