Merge branch 'MDL-53562-forum-reply-re-MOODLE_29_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_29_STABLE

This commit is contained in:
Dan Poltawski
2016-03-26 10:36:39 +08:00
2 changed files with 32 additions and 2 deletions
+2 -2
View File
@@ -791,8 +791,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!
+30
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;
@@ -833,4 +835,32 @@ class mod_forum_mail_testcase extends advanced_testcase {
$this->assertEquals($author->id, $message->useridfrom);
$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);
}
}