mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-36754 mod_forum: Use token for emailed pictures
This commit is contained in:
parent
88d89512e4
commit
7fa3089753
@ -56,9 +56,16 @@ class renderer extends \mod_forum_renderer {
|
||||
*/
|
||||
public function format_message_text($cm, $post) {
|
||||
$context = \context_module::instance($cm->id);
|
||||
$message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php',
|
||||
$message = file_rewrite_pluginfile_urls(
|
||||
$post->message,
|
||||
'pluginfile.php',
|
||||
$context->id,
|
||||
'mod_forum', 'post', $post->id);
|
||||
'mod_forum',
|
||||
'post',
|
||||
$post->id,
|
||||
[
|
||||
'includetoken' => true,
|
||||
]);
|
||||
$options = new \stdClass();
|
||||
$options->para = true;
|
||||
$options->context = $context;
|
||||
|
@ -53,9 +53,17 @@ class renderer_textemail extends \mod_forum\output\email\renderer_textemail {
|
||||
* @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);
|
||||
$context = \context_module::instance($cm->id);
|
||||
$message = file_rewrite_pluginfile_urls(
|
||||
$post->message,
|
||||
'pluginfile.php',
|
||||
$context->id,
|
||||
'mod_forum',
|
||||
'post',
|
||||
$post->id,
|
||||
[
|
||||
'includetoken' => true,
|
||||
]);
|
||||
return format_text_email($message, $post->messageformat);
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,17 @@ class renderer_textemail extends \mod_forum\output\email\renderer_textemail {
|
||||
* @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);
|
||||
$context = \context_module::instance($cm->id);
|
||||
$message = file_rewrite_pluginfile_urls(
|
||||
$post->message,
|
||||
'pluginfile.php',
|
||||
$context->id,
|
||||
'mod_forum',
|
||||
'post',
|
||||
$post->id,
|
||||
[
|
||||
'includetoken' => true,
|
||||
]);
|
||||
return format_text_email($message, $post->messageformat);
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ class forum_post implements \renderable, \templatable {
|
||||
*
|
||||
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
|
||||
* @param bool $plaintext Whethe the target is a plaintext target
|
||||
* @return stdClass Data ready for use in a mustache template
|
||||
* @return array Data ready for use in a mustache template
|
||||
*/
|
||||
public function export_for_template(\renderer_base $renderer, $plaintext = false) {
|
||||
if ($plaintext) {
|
||||
@ -149,7 +149,7 @@ class forum_post implements \renderable, \templatable {
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
|
||||
* @return stdClass Data ready for use in a mustache template
|
||||
* @return array Data ready for use in a mustache template
|
||||
*/
|
||||
protected function export_for_template_text(\mod_forum_renderer $renderer) {
|
||||
return array(
|
||||
@ -180,9 +180,9 @@ class forum_post implements \renderable, \templatable {
|
||||
'discussionlink' => $this->get_discussionlink(),
|
||||
|
||||
'authorlink' => $this->get_authorlink(),
|
||||
'authorpicture' => $this->get_author_picture(),
|
||||
'authorpicture' => $this->get_author_picture($renderer),
|
||||
|
||||
'grouppicture' => $this->get_group_picture(),
|
||||
'grouppicture' => $this->get_group_picture($renderer),
|
||||
);
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ class forum_post implements \renderable, \templatable {
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @param \mod_forum_renderer $renderer The render to be used for formatting the message and attachments
|
||||
* @return stdClass Data ready for use in a mustache template
|
||||
* @return array Data ready for use in a mustache template
|
||||
*/
|
||||
protected function export_for_template_html(\mod_forum_renderer $renderer) {
|
||||
return array(
|
||||
@ -221,9 +221,9 @@ class forum_post implements \renderable, \templatable {
|
||||
'discussionlink' => $this->get_discussionlink(),
|
||||
|
||||
'authorlink' => $this->get_authorlink(),
|
||||
'authorpicture' => $this->get_author_picture(),
|
||||
'authorpicture' => $this->get_author_picture($renderer),
|
||||
|
||||
'grouppicture' => $this->get_group_picture(),
|
||||
'grouppicture' => $this->get_group_picture($renderer),
|
||||
);
|
||||
}
|
||||
|
||||
@ -543,20 +543,20 @@ class forum_post implements \renderable, \templatable {
|
||||
/**
|
||||
* The HTML for the author's user picture.
|
||||
*
|
||||
* @param \renderer_base $renderer
|
||||
* @return string
|
||||
*/
|
||||
public function get_author_picture() {
|
||||
global $OUTPUT;
|
||||
|
||||
return $OUTPUT->user_picture($this->author, array('courseid' => $this->course->id));
|
||||
public function get_author_picture(\renderer_base $renderer) {
|
||||
return $renderer->user_picture($this->author, array('courseid' => $this->course->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* The HTML for a group picture.
|
||||
*
|
||||
* @param \renderer_base $renderer
|
||||
* @return string
|
||||
*/
|
||||
public function get_group_picture() {
|
||||
public function get_group_picture(\renderer_base $renderer) {
|
||||
if (isset($this->userfrom->groups)) {
|
||||
$groups = $this->userfrom->groups[$this->forum->id];
|
||||
} else {
|
||||
@ -564,7 +564,7 @@ class forum_post implements \renderable, \templatable {
|
||||
}
|
||||
|
||||
if ($this->get_is_firstpost()) {
|
||||
return print_group_picture($groups, $this->course->id, false, true, true);
|
||||
return print_group_picture($groups, $this->course->id, false, true, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1042,7 +1042,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
'<div class="attachments">( *\n *)?<a href',
|
||||
'<div class="subject">\n.*HTML text and image', '>Moodle Forum',
|
||||
'<p>Welcome to Moodle, '
|
||||
.'<img src="https://www.example.com/moodle/pluginfile.php/\d+/mod_forum/post/\d+/'
|
||||
.'<img src="https://www.example.com/moodle/tokenpluginfile.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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user