]> git.mjollnir.org Git - moodle.git/commitdiff
- Prevent users from replying in groups other then own.
authormoodler <moodler>
Tue, 20 Jan 2004 13:51:27 +0000 (13:51 +0000)
committermoodler <moodler>
Tue, 20 Jan 2004 13:51:27 +0000 (13:51 +0000)
- groups menu at discussion level

mod/forum/discuss.php
mod/forum/lib.php

index b1b3cd15f0c5131d0e69a7f303a8ab5e5b4cc46a..7271bb8b94f113dbd7c7915f15176a462065131b 100644 (file)
                  "$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 "<table width=\"100%\"><tr><td width=\"33%\">&nbsp;</td><td width=\"33%\">";
+/// Print the controls across the top
+
+    echo "<table width=\"100%\"><tr><td width=\"33%\">";
+
+    if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
+        if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
+
+            echo '<table><tr><td>';
+            if ($groupmode == VISIBLEGROUPS) {
+                print_string('groupsvisible');
+            } else {
+                print_string('groupsseparate');
+            }
+            echo ':';
+            echo '</td><td nowrap="nowrap" align="left" width="50%">';
+            popup_form("view.php?id=$cm->id&group=", $groups, 'selectgroup', $currentgroup, "", "", "", false, "self");
+            echo '</tr></table>';
+
+            echo '</td>';
+        }
+    }
+
+    echo "</td><td width=\"33%\">";
     forum_print_mode_form($discussion->id, $displaymode);
+
     echo "</td><td width=\"33%\">";
     if (isteacher($course->id)) {    // Popup menu to allow discussions to be moved to other forums
         if ($forums = get_all_instances_in_course("forum", $course)) {
         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);
 
index 4212ce3c517c41f1b4de488cad294452ee81c31f..77da89770cb02d49c4c4ced11a34b36fffd8159c 100644 (file)
@@ -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;