From 7613e6d7d11414f5edb78e625525eb6365b6b663 Mon Sep 17 00:00:00 2001 From: vyshane Date: Wed, 9 Aug 2006 09:18:31 +0000 Subject: [PATCH] More updates in lib.php --- mod/forum/lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index fe8084cc77..dedc7a8977 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1453,7 +1453,13 @@ function forum_get_discussions($forum="0", $forumsort="d.timemodified DESC", $timelimit = ''; if (!empty($CFG->forum_enabletimedposts)) { - if (!((isadmin() and !empty($CFG->admineditalways)) || isteacher(get_field('forum', 'course', 'id', $forum)))) { + + if (!$cm = get_coursemodule_from_instance('forum', $forum)) { + error('Course Module ID was incorrect'); + } + $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); + + if (!has_capability('mod/forum:viewhiddentimedposts', $modcontext->id)) { $now = time(); $timelimit = " AND ((d.timestart = 0 OR d.timestart <= '$now') AND (d.timeend = 0 OR d.timeend > '$now')"; if (!empty($USER->id)) { @@ -1676,6 +1682,16 @@ function forum_make_mail_post(&$post, $user, $touser, $course, static $formattedtext; // Cached version of formatted text for a post static $formattedtextid; // The ID number of the post + + if (!$forumid = get_record('discussion', 'id', $post->discussion)) { + error('Could not get the forum id for the discussion the post belongs to'); + } + if (!$cm = get_coursemodule_from_instance('forum', $forumid)) { + error('Course Module ID was incorrect'); + } + $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); + + if (empty($formattedtextid) or $formattedtextid != $post->id) { // Recalculate the formatting $options = new Object; $options->para = true; @@ -1696,7 +1712,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course, } $output .= '
'.format_string($post->subject).'
'; - $fullname = fullname($user, isteacher($course->id)); + $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $modcontext->id);); $by->name = ''.$fullname.''; $by->date = userdate($post->modified, '', $touser->timezone); $output .= '
'.get_string('bynameondate', 'forum', $by).'
'; -- 2.39.5