MDL-53562 forum: Fixed missing forum subject Re: prefix

This commit is contained in:
Brendan Heywood
2016-03-21 19:41:40 +11:00
parent fed66ad9e2
commit 318e5cb302
2 changed files with 31 additions and 2 deletions
+2 -2
View File
@@ -826,8 +826,8 @@ function forum_cron() {
// MS Outlook / Office uses poorly documented and non standard headers, including
// Thread-Topic which overrides the Subject and shouldn't contain Re: or Fwd: etc.
$a->subject = $discussion->name;
$postsubject = html_to_text(get_string('postmailsubject', 'forum', $a), 0);
$userfrom->customheaders[] = "Thread-Topic: $postsubject";
$threadtopic = html_to_text(get_string('postmailsubject', 'forum', $a), 0);
$userfrom->customheaders[] = "Thread-Topic: $threadtopic";
$userfrom->customheaders[] = "Thread-Index: " . substr($rootid, 1, 28);
// Send the post now!
+29
View File
@@ -184,6 +184,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
// Add a post to the discussion.
$record = new stdClass();
$record->course = $forum->course;
$strre = get_string('re', 'forum');
$record->subject = $strre . ' ' . $discussion->subject;
$record->userid = $author->id;
$record->forum = $forum->id;
$record->discussion = $discussion->id;
@@ -834,6 +836,33 @@ class mod_forum_mail_testcase extends advanced_testcase {
$this->assertEquals($expectedsubject, $message->subject);
}
/**
* Test inital email and reply email subjects
*/
public function test_subjects() {
$this->resetAfterTest(true);
$course = $this->getDataGenerator()->create_course();
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_FORCESUBSCRIBE);
$forum = $this->getDataGenerator()->create_module('forum', $options);
list($author) = $this->helper_create_users($course, 1);
list($commenter) = $this->helper_create_users($course, 1);
$strre = get_string('re', 'forum');
// New posts should not have Re: in the subject.
list($discussion, $post) = $this->helper_post_to_forum($forum, $author);
$messages = $this->helper_run_cron_check_count($post, 2);
$this->assertNotContains($strre, $messages[0]->subject);
// Replies should have Re: in the subject.
$reply = $this->helper_post_to_discussion($forum, $discussion, $commenter);
$messages = $this->helper_run_cron_check_count($reply, 2);
$this->assertContains($strre, $messages[0]->subject);
}
/**
* dataProvider for test_forum_post_email_templates().
*/