From: moodler Date: Tue, 20 Jan 2004 13:51:27 +0000 (+0000) Subject: - Prevent users from replying in groups other then own. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c6d691dc287f126061f1d805b2445af3b2940bdb;p=moodle.git - Prevent users from replying in groups other then own. - groups menu at discussion level --- diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index b1b3cd15f0..7271bb8b94 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -92,29 +92,67 @@ "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); } + /// Check to see if groups are being used in this forum /// 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 = NULL; /// No override one way or the other $groupmode = groupmode($course, $cm); - if ($groupmode == SEPARATEGROUPS and !isteacheredit($course->id)) { // Groups must be kept separate - require_login(); + if ($groupmode and !isteacheredit($course->id)) { // Groups must be kept separate if (!$toppost = get_record("forum_posts", "id", $discussion->firstpost)) { error("Could not find the top post of the discussion"); } if (!$group = user_group($course->id, $toppost->userid)) { // Find the topic's group error("Could not find the appropriate group of this discussion"); } - if (mygroupid($course->id) != $group->id) { - print_heading("Sorry, you can't see this discussion because you are not in this group"); - print_footer(); - die; + + if ($groupmode == SEPARATEGROUPS) { + require_login(); + + if (mygroupid($course->id) == $group->id) { + $canreply = true; + } else { + print_heading("Sorry, you can't see this discussion because you are not in this group"); + print_footer(); + die; + } + + } else if ($groupmode == VISIBLEGROUPS) { + if (mygroupid($course->id) == $group->id) { + $canreply = true; + } } } - echo "
 "; +/// Print the controls across the top + + echo "'; + } + } + + echo "
"; + + if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) { + if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { + + echo '
'; + if ($groupmode == VISIBLEGROUPS) { + print_string('groupsvisible'); + } else { + print_string('groupsseparate'); + } + echo ':'; + echo ''; + popup_form("view.php?id=$cm->id&group=", $groups, 'selectgroup', $currentgroup, "", "", "", false, "self"); + echo '
'; + + echo '
"; forum_print_mode_form($discussion->id, $displaymode); + echo ""; if (isteacher($course->id)) { // Popup menu to allow discussions to be moved to other forums if ($forums = get_all_instances_in_course("forum", $course)) { @@ -138,7 +176,11 @@ notify(get_string("discussionmoved", "forum", $forum->name)); } - forum_print_discussion($course, $forum, $discussion, $post, $displaymode); + +/// Print the actual discussion + + forum_print_discussion($course, $forum, $discussion, $post, $displaymode, $canreply); + print_footer($course); diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 4212ce3c51..77da89770c 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2173,7 +2173,7 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, } } -function forum_print_discussion($course, $forum, $discussion, $post, $mode) { +function forum_print_discussion($course, $forum, $discussion, $post, $mode, $canreply=NULL) { global $USER; @@ -2182,7 +2182,11 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode) { } else { $ownpost = false; } - $reply = forum_user_can_post($forum); + if ($canreply === NULL) { + $reply = forum_user_can_post($forum); + } else { + $reply = $canreply; + } $ratings = NULL; $ratingsmenuused = false;