mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-48148 mod_forum: Use the standard forum reply subject as default
When a user replies by e-mail, the course name has been included in the original e-mail. As a result, the reply subject becomes longer and longer. In cases whether either: * the discussion name; or * the replied-to-post subject is present in the mail subject, the standard reply subject is instead used.
This commit is contained in:
parent
2611dd99d3
commit
338ee3d6bb
@ -133,12 +133,32 @@ class reply_handler extends \core\message\inbound\handler {
|
||||
throw new \core\message\inbound\processing_failed_exception('messageinboundthresholdhit', 'mod_forum', $data);
|
||||
}
|
||||
|
||||
$subject = clean_param($messagedata->envelope->subject, PARAM_TEXT);
|
||||
$restring = get_string('re', 'forum');
|
||||
if (strpos($subject, $discussion->name)) {
|
||||
// The discussion name is mentioned in the e-mail subject. This is probably just the standard reply. Use the
|
||||
// standard reply subject instead.
|
||||
$newsubject = $restring . ' ' . $discussion->name;
|
||||
mtrace("--> Note: Post subject matched discussion name. Optimising from {$subject} to {$newsubject}");
|
||||
$subject = $newsubject;
|
||||
} else if (strpos($subject, $post->subject)) {
|
||||
// The replied-to post's subject is mentioned in the e-mail subject.
|
||||
// Use the previous post's subject instead of the e-mail subject.
|
||||
$newsubject = $post->subject;
|
||||
if (!strpos($restring, $post->subject)) {
|
||||
// The previous post did not contain a re string, add it.
|
||||
$newsubject = $restring . ' ' . $subject;
|
||||
}
|
||||
mtrace("--> Note: Post subject matched original post subject. Optimising from {$subject} to {$newsubject}");
|
||||
$subject = $newsubject;
|
||||
}
|
||||
|
||||
$addpost = new \stdClass();
|
||||
$addpost->course = $course->id;
|
||||
$addpost->forum = $forum->id;
|
||||
$addpost->discussion = $discussion->id;
|
||||
$addpost->modified = $messagedata->timestamp;
|
||||
$addpost->subject = clean_param($messagedata->envelope->subject, PARAM_TEXT);
|
||||
$addpost->subject = $subject;
|
||||
$addpost->parent = $post->id;
|
||||
$addpost->itemid = file_get_unused_draft_itemid();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user