From 9bb71899c0774528f588eaf82fe4ba34bde1511b Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 22 Jan 2015 13:19:07 +0530 Subject: [PATCH] MDL-48212 messages: show reply allowed message only when needed --- mod/forum/lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index ef99acc00d7..9ad37dc345e 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -775,7 +775,7 @@ function forum_cron() { // Send the post now! mtrace('Sending ', ''); - $eventdata = new stdClass(); + $eventdata = new \core\message\message(); $eventdata->component = 'mod_forum'; $eventdata->name = 'posts'; $eventdata->userfrom = $userfrom; @@ -786,6 +786,14 @@ function forum_cron() { $eventdata->fullmessagehtml = $posthtml; $eventdata->notification = 1; $eventdata->replyto = $replyaddress; + if (!empty($replyaddress)) { + // Add extra text to email messages if they can reply back. + $textfooter = "\n\n" . get_string('replytopostbyemail', 'mod_forum'); + $htmlfooter = html_writer::tag('p', get_string('replytopostbyemail', 'mod_forum')); + $additionalcontent = array('fullmessage' => array('footer' => $textfooter), + 'fullmessagehtml' => array('footer' => $htmlfooter)); + $eventdata->set_additional_content('email', $additionalcontent); + } // If forum_replytouser is not set then send mail using the noreplyaddress. if (empty($CFG->forum_replytouser)) { @@ -1245,10 +1253,6 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro $posttext .= get_string("digestmailpost", "forum"); $posttext .= ": {$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}\n"; - if ($replyaddress) { - $posttext .= "\n\n" . get_string('replytopostbyemail', 'mod_forum'); - } - return $posttext; } @@ -1303,10 +1307,6 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro } $posthtml .= forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false); - if ($replyaddress) { - $posthtml .= html_writer::tag('p', get_string('replytopostbyemail', 'mod_forum')); - } - $footerlinks = array(); if ($canunsubscribe) { if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {