Commit 151d7dd0 authored by Richard Mansfield's avatar Richard Mansfield

Send forum emails in html and text

parent 17f5328c
......@@ -67,6 +67,14 @@ $string['edittitle'] = 'Edit forum';
$string['edittopic'] = 'Edit topic';
$string['edittopicsuccess'] = 'Topic edited successfully';
$string['forumname'] = 'Forum Name';
$string['forumposthtmltemplate'] = "<div style=\"padding: 0.5em 0; border-bottom: 1px solid #999;\"><strong>%s by %s</strong><br>%s</div>
<div style=\"margin: 1em 0;\">%s</div>
<div style=\"font-size: smaller; border-top: 1px solid #999;\">
<p>To see and reply to the post online, follow this link:<br><a href=\"%s\">%s</a></p>
<p>To unsubscribe from this %s, visit: <a href=\"%s\">%s</a></p>
</div>";
$string['forumposttemplate'] = "%s by %s
%s
------------------------------------------------------------------------
......
......@@ -484,6 +484,7 @@ class ActivityTypeInteractionForumNewPost extends ActivityTypePlugin {
}
$posttime = strftime(get_string('strftimedaydatetime'), $post->ctime);
$htmlbody = $post->body;
$textbody = trim(html2text($post->body));
$postlink = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topicid . '#post' . $this->postid;
......@@ -509,6 +510,15 @@ class ActivityTypeInteractionForumNewPost extends ActivityTypePlugin {
$type,
$unsubscribelink
);
$user->htmlmessage = get_string_from_language($lang, 'forumposthtmltemplate', 'interaction.forum',
$post->subject ? $post->subject : get_string_from_language($lang, 're', 'interaction.forum', $post->topicsubject),
display_name($post->poster, $user),
$posttime,
$htmlbody,
$postlink, $postlink,
$type,
$unsubscribelink, $unsubscribelink
);
}
}
......
......@@ -32,9 +32,14 @@ class PluginNotificationEmail extends PluginNotification {
public static function notify_user($user, $data) {
$messagehtml = null;
if (!empty($data->overridemessagecontents)) {
$subject = $data->subject;
$messagebody = $data->message;
if (!empty($user->htmlmessage)) {
$messagehtml = $user->htmlmessage;
}
}
else {
$lang = (empty($user->lang) || $user->lang == 'default') ? get_config('lang') : $user->lang;
......@@ -75,7 +80,7 @@ class PluginNotificationEmail extends PluginNotification {
$userfrom->email = get_config('noreplyaddress');
}
}
email_user($user, $userfrom, $subject, $messagebody, null, !empty($data->customheaders) ? $data->customheaders : null);
email_user($user, $userfrom, $subject, $messagebody, $messagehtml, !empty($data->customheaders) ? $data->customheaders : null);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment