I have looked everywhere I can think of and I haven't found a single reference to this. I can subscribe to a topic or a forum and then as soon as somebody posts something new, I get an email saying that something new has been posted, and I should go visit the forum.
What I would like to do is have the body of the post included in the email. Is this possible? If it is not currently possible, can somebody point to the proper file so that I can go try to add it?
You have to change the email templates as well as add some code to insert the post message into the templates. The email templates are just text files with place holders that get dynamically replaced with stuff like the forum name, post subject, etc...so you just have to create a new place holder, in your case "{POST_TEXT}" and then fill it.
Add post text to email notifications. Edit the files...
Add post text to email notifications. Edit the files...
- /includes/functions_posting.php
Around line 2405 strip bbcode from $data['message'] and pass it to the user_notification() function call...- CODE: SELECT ALL
php
// Send Notifications
if ($mode != 'edit' && $mode != 'delete' && ($auth->acl_get('f_noapprove', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])))
{
//remove bbcode from text
$stripped_post_text = $data['message'];
strip_bbcode($stripped_post_text, $data['bbcode_uid']);
user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $stripped_post_text);
}
Around line 1096 added parameter $post_text='' (empty string as default to make it optional, in case its called from elsewhere) to parameter list...- CODE: SELECT ALL
php
/**
* User Notification
*/
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id, $post_text='')
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
Around line 1255 added the array key/value pair 'POST_TEXT' => htmlspecialchars_decode($post_text), ...- CODE: SELECT ALL
php
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($addr['name']),
'TOPIC_TITLE' => htmlspecialchars_decode($topic_title),
'FORUM_NAME' => htmlspecialchars_decode($forum_name),
'POST_TEXT' => htmlspecialchars_decode($post_text),
'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id",
'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id",
'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=$post_id",
'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&unwatch=topic",
'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&unwatch=forum",
));
- /language/en/email/forum_notify.txt, added "{POST_TEXT}" (with quotation marks) and some spacing...place holder post text
- /language/en/email/newtopic_notify.txt, added "{POST_TEXT}" (with quotation marks) and some spacing...place holder post text
- /language/en/email/topic_notify.txt, added "{POST_TEXT}" (with quotation marks) and some spacing...place holder post text
Sorry, that last part wasn't too clear. Those text files are the email templates. Each contains plain text like...
The stuff in brackets are placeholders. The function messenger->assign_vars() is used to add a key value pair for POST_TEXT=>$post_text which the messenger class later uses to do a find and replace of all the place holders before sending the email. I added the place holder "{POST_TEXT}" to this and the other two files so that the code changes from functions_posting.php would pop the post text in there. Just reformat the rest of the plain text however you want the email to be displayed.
- CODE: SELECT ALL
Subject: New topic notification - "{FORUM_NAME}"
Hello {USERNAME},
You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic since your last visit, "{TOPIC_TITLE}".
"{POST_TEXT}"
You can use the following link to view forum, no more notifications will be sent until you visit the forum.
{U_FORUM}
If you no longer wish to watch this forum you can either click the "Unsubscribe forum" link found in the forum above, or by clicking the following link:
{U_STOP_WATCHING_FORUM}
{EMAIL_SIG}
The stuff in brackets are placeholders. The function messenger->assign_vars() is used to add a key value pair for POST_TEXT=>$post_text which the messenger class later uses to do a find and replace of all the place holders before sending the email. I added the place holder "{POST_TEXT}" to this and the other two files so that the code changes from functions_posting.php would pop the post text in there. Just reformat the rest of the plain text however you want the email to be displayed.
没有评论:
发表评论