Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-25944 fix broken images in forum emails and fix invalid $group va…

…riable name
  • Loading branch information...
commit 18ff4d427ee46c32dc6322e5643a98d15de905b7 1 parent 99faefb
@skodak skodak authored
Showing with 11 additions and 10 deletions.
  1. +11 −10 mod/forum/lib.php
View
21 mod/forum/lib.php
@@ -980,15 +980,15 @@ function forum_cron() {
function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $bare = false) {
global $CFG, $USER;
+ $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+
if (!isset($userto->viewfullnames[$forum->id])) {
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
} else {
$viewfullnames = $userto->viewfullnames[$forum->id];
}
if (!isset($userto->canpost[$discussion->id])) {
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$canreply = forum_user_can_post($forum, $discussion, $userto, $cm, $course, $modcontext);
} else {
$canreply = $userto->canpost[$discussion->id];
@@ -1014,6 +1014,9 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro
}
}
+ // add absolute file links
+ $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
+
$posttext .= "\n---------------------------------------------------------------------\n";
$posttext .= format_string($post->subject,true);
if ($bare) {
@@ -2979,16 +2982,17 @@ function forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfro
global $CFG, $OUTPUT;
+ $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+
if (!isset($userto->viewfullnames[$forum->id])) {
- if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
} else {
$viewfullnames = $userto->viewfullnames[$forum->id];
}
+ // add absolute file links
+ $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
+
// format the post body
$options = new stdClass();
$options->para = true;
@@ -3020,10 +3024,7 @@ function forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfro
if (isset($userfrom->groups)) {
$groups = $userfrom->groups[$forum->id];
} else {
- if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
- print_error('invalidcoursemodule');
- }
- $group = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
+ $groups = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
}
if ($groups) {
Please sign in to comment.
Something went wrong with that request. Please try again.