]> git.mjollnir.org Git - moodle.git/commitdiff
merged fix for MDL-8864, users with no replypost capabilitiy can see reply link
authortoyomoyo <toyomoyo>
Tue, 13 Mar 2007 04:37:57 +0000 (04:37 +0000)
committertoyomoyo <toyomoyo>
Tue, 13 Mar 2007 04:37:57 +0000 (04:37 +0000)
mod/forum/discuss.php

index 369a5c0b92e6049f4525abd0d57ed620400ae5dc..425e691fa18459f4744aae83b297df475d564593 100644 (file)
 /// 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 '<table width="100%" class="discussioncontrols"><tr><td>';