From c57da11991ed35e4ccbae0eb8bcd3b3e8971a546 Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 10 Jan 2008 23:13:30 +0000 Subject: [PATCH] MDL-12921 Using visible groups in Q&A Forums student can't reply to discussions for All participants (including groups code cleanup); merged from MOODLE_19_STABLE --- mod/forum/discuss.php | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 05a14d78c5d..e9bfb854b27 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -154,30 +154,34 @@ $capname = 'mod/forum:replypost'; } - $groupmode = groups_get_activity_groupmode($cm); - if ($canreply = has_capability($capname, $modcontext)) { - - if ($groupmode && !has_capability('moodle/site:accessallgroups', $modcontext)) { - // Groups must be kept separate - //change this to groups_is_member - $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) || (groups_is_member($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; + $canreply = false; + if (has_capability($capname, $modcontext)) { + $groupmode = groups_get_activity_groupmode($cm); + if ($groupmode) { + if (has_capability('moodle/site:accessallgroups', $modcontext)) { + $canreply = true; + } else { + if ($groupmode == SEPARATEGROUPS) { + require_login(); + if ($discussion->groupid == -1) { + // can not reply to discussions for "All participants" in separate mode without accessallgroups cap + } else if (groups_is_member($discussion->groupid)) { + $canreply = true; + } else { + // this should not happen + print_heading("Sorry, you can't see this discussion because you are not in this group"); + print_footer($course); + die; + } + + } else if ($groupmode == VISIBLEGROUPS) { + if ($discussion->groupid == -1 or groups_is_member($discussion->groupid)) { + $canreply = true; + } } - - } else if ($groupmode == VISIBLEGROUPS) { - $canreply = ( (empty($mygroupid) && $discussion->groupid == -1) || - (groups_is_member($discussion->groupid) || $mygroupid == $discussion->groupid) ); - } + } + } else { + $canreply = true; } } else { // allow guests to see the link $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);