$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)) {
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;
}
$output .= '<div class="subject">'.format_string($post->subject).'</div>';
- $fullname = fullname($user, isteacher($course->id));
+ $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $modcontext->id););
$by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.$fullname.'</a>';
$by->date = userdate($post->modified, '', $touser->timezone);
$output .= '<div class="author">'.get_string('bynameondate', 'forum', $by).'</div>';