From: toyomoyo Date: Tue, 13 Mar 2007 04:37:57 +0000 (+0000) Subject: merged fix for MDL-8864, users with no replypost capabilitiy can see reply link X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9276d74255a5d049a2f5ed0f0bf601d9fde45d2b;p=moodle.git merged fix for MDL-8864, users with no replypost capabilitiy can see reply link --- diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 369a5c0b92..425e691fa1 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -161,47 +161,40 @@ /// If so, make sure the current person is allowed to see this discussion /// Also, if we know they should be able to reply, then explicitly set $canreply - $canreply = true; /// By default, because guests etc will be asked to log in - $groupmode = groupmode($course, $cm); + if ($forum->type == 'news') { + $capname = 'mod/forum:replynews'; + } else { + $capname = 'mod/forum:replypost'; + } + $groupmode = groupmode($course, $cm); + if ($canreply = has_capability($capname, $modcontext)) { - if ($groupmode && !has_capability('moodle/site:accessallgroups', $modcontext)) { - // Groups must be kept separate - //change this to ismember - $mygroupid = mygroupid($course->id); //only useful if 0, otherwise it's an array now - if ($groupmode == SEPARATEGROUPS) { - require_login(); - - if ((empty($mygroupid) and $discussion->groupid == -1) || (ismember($discussion->groupid) || $mygroupid == $discussion->groupid)) { - $canreply = true; - } elseif ($discussion->groupid == -1) { - $canreply = false; - } else { - print_heading("Sorry, you can't see this discussion because you are not in this group"); - print_footer($course); - die; - } + + if ($groupmode && !has_capability('moodle/site:accessallgroups', $modcontext)) { + // Groups must be kept separate + //change this to ismember + $mygroupid = mygroupid($course->id); //only useful if 0, otherwise it's an array now + if ($groupmode == SEPARATEGROUPS) { + require_login(); + + if ((empty($mygroupid) and $discussion->groupid == -1) || (ismember($discussion->groupid) || $mygroupid == $discussion->groupid)) { + // $canreply = true; + } elseif ($discussion->groupid == -1) { + $canreply = false; + } else { + print_heading("Sorry, you can't see this discussion because you are not in this group"); + print_footer($course); + die; + } - } else if ($groupmode == VISIBLEGROUPS) { - $canreply = ( (empty($mygroupid) && $discussion->groupid == -1) || + } else if ($groupmode == VISIBLEGROUPS) { + $canreply = ( (empty($mygroupid) && $discussion->groupid == -1) || (ismember($discussion->groupid) || $mygroupid == $discussion->groupid) ); - } - } else { - if ($forum->type == 'news') { - $capname = 'mod/forum:replynews'; - } else { - $capname = 'mod/forum:replypost'; - } - - if (!has_capability($capname, $modcontext)) { - $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); - if (!has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here! - $canreply = false; } } } - /// Print the controls across the top echo '
';