mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'm31_MDL-53622_Fix_Missing_Rewrite_Pluginfile_URLs' of https://github.com/scara/moodle
This commit is contained in:
commit
17ed403974
@ -53,9 +53,12 @@ class renderer extends \mod_forum_renderer {
|
||||
* @return string
|
||||
*/
|
||||
public function format_message_text($cm, $post) {
|
||||
$message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php',
|
||||
\context_module::instance($cm->id)->id,
|
||||
'mod_forum', 'post', $post->id);
|
||||
$options = new \stdClass();
|
||||
$options->para = true;
|
||||
return format_text($post->message, $post->messageformat, $options);
|
||||
return format_text($message, $post->messageformat, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -945,6 +945,24 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
'Hello Moodle&', 'Welcome to Moodle&');
|
||||
$textcases['Text mail with ampersands everywhere'] = array('data' => $newcase);
|
||||
|
||||
// Text+image message i.e. @@PLUGINFILE@@ token handling.
|
||||
$newcase = $base;
|
||||
$newcase['forums'][0]['forumposts'][0]['name'] = 'Text and image';
|
||||
$newcase['forums'][0]['forumposts'][0]['message'] = 'Welcome to Moodle, '
|
||||
.'@@PLUGINFILE@@/Screen%20Shot%202016-03-22%20at%205.54.36%20AM%20%281%29.png !';
|
||||
$newcase['expectations'][0]['subject'] = '.*101.*Text and image';
|
||||
$newcase['expectations'][0]['contents'] = array(
|
||||
'~{$a',
|
||||
'~&(amp|lt|gt|quot|\#039);(?!course)',
|
||||
'Attachment example.txt:\n' .
|
||||
'http://www.example.com/moodle/pluginfile.php/\d*/mod_forum/attachment/\d*/example.txt\n',
|
||||
'Text and image', 'Moodle Forum',
|
||||
'Welcome to Moodle, *\n.*'
|
||||
.'http://www.example.com/moodle/pluginfile.php/\d+/mod_forum/post/\d+/'
|
||||
.'Screen%20Shot%202016-03-22%20at%205\.54\.36%20AM%20%281%29\.png *\n.*!',
|
||||
'Love Moodle', '1\d1');
|
||||
$textcases['Text mail with text+image message i.e. @@PLUGINFILE@@ token handling'] = array('data' => $newcase);
|
||||
|
||||
// Now the html cases.
|
||||
$htmlcases = array();
|
||||
|
||||
@ -973,6 +991,25 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
'>Welcome.*Moodle\'">&', '>Love Moodle&\#039;">&', '>101\'">&');
|
||||
$htmlcases['HTML mail with quotes, gt, lt and ampersand everywhere'] = array('data' => $newcase);
|
||||
|
||||
// Text+image message i.e. @@PLUGINFILE@@ token handling.
|
||||
$newcase = $htmlbase;
|
||||
$newcase['forums'][0]['forumposts'][0]['name'] = 'HTML text and image';
|
||||
$newcase['forums'][0]['forumposts'][0]['message'] = '<p>Welcome to Moodle, '
|
||||
.'<img src="@@PLUGINFILE@@/Screen%20Shot%202016-03-22%20at%205.54.36%20AM%20%281%29.png"'
|
||||
.' alt="" width="200" height="393" class="img-responsive" />!</p>';
|
||||
$newcase['expectations'][0]['subject'] = '.*101.*HTML text and image';
|
||||
$newcase['expectations'][0]['contents'] = array(
|
||||
'~{\$a',
|
||||
'~&(amp|lt|gt|quot|\#039);(?!course)',
|
||||
'<div class="attachments">( *\n *)?<a href',
|
||||
'<div class="subject">\n.*HTML text and image', '>Moodle Forum',
|
||||
'<p>Welcome to Moodle, '
|
||||
.'<img src="http://www.example.com/moodle/pluginfile.php/\d+/mod_forum/post/\d+/'
|
||||
.'Screen%20Shot%202016-03-22%20at%205\.54\.36%20AM%20%281%29\.png"'
|
||||
.' alt="" width="200" height="393" class="img-responsive" />!</p>',
|
||||
'>Love Moodle', '>1\d1');
|
||||
$htmlcases['HTML mail with text+image message i.e. @@PLUGINFILE@@ token handling'] = array('data' => $newcase);
|
||||
|
||||
return $textcases + $htmlcases;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user