From ee8e0008230c2f07432e2231a8fe072cf7900a1c Mon Sep 17 00:00:00 2001 From: vyshane Date: Tue, 26 Sep 2006 02:02:27 +0000 Subject: [PATCH] Fixed bug in forum_make_mail_post() --- mod/forum/lib.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 7900ba398b..0c959b2956 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1727,19 +1727,18 @@ function forum_get_course_forum($courseid, $type) { function forum_make_mail_post(&$post, $user, $touser, $course, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") { -// Given the data about a posting, builds up the HTML to display it and -// returns the HTML in a string. This is designed for sending via HTML email. + + // Given the data about a posting, builds up the HTML to display it and + // returns the HTML in a string. This is designed for sending via HTML email. global $CFG; static $formattedtext; // Cached version of formatted text for a post static $formattedtextid; // The ID number of the post - - if (!$forum = get_record('forum', 'id', $post->discussion)) { - mtrace('Could not get the forum for the discussion the post belongs to'); - } - if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) { + $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion); + + if (!$cm = get_coursemodule_from_instance('forum', $post->forum)) { mtrace('Course Module ID was incorrect'); } $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -1765,7 +1764,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course, } $output .= '
'.format_string($post->subject).'
'; - $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $modcontext)); + $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $modcontext, $touser->id)); $by->name = ''.$fullname.''; $by->date = userdate($post->modified, '', $touser->timezone); $output .= '
'.get_string('bynameondate', 'forum', $by).'
'; @@ -1783,7 +1782,6 @@ function forum_make_mail_post(&$post, $user, $touser, $course, if ($post->attachment) { $post->course = $course->id; - $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion); $output .= '
'; $output .= forum_print_attachments($post, 'html'); $output .= "
"; @@ -1791,9 +1789,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course, $output .= $formattedtext; - /// Commands - $commands = array(); if ($post->parent) { @@ -1815,9 +1811,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course, $output .= implode(' | ', $commands); $output .= ''; - /// Context link to post if required - if ($link) { $output .= '