]> git.mjollnir.org Git - moodle.git/commitdiff
Added moodle/site:viewparticipants
authorvyshane <vyshane>
Mon, 18 Sep 2006 09:02:12 +0000 (09:02 +0000)
committervyshane <vyshane>
Mon, 18 Sep 2006 09:02:12 +0000 (09:02 +0000)
blocks/participants/block_participants.php
lib/db/access.php

index ed06386d383b68d62f0b4e5a7dfd4b7db6bb3946..a16b1def7c3ff20cb62c5e79b930ab4fccac2879 100644 (file)
@@ -15,16 +15,17 @@ class block_participants extends block_list {
                        return '';  
                }
                
-               $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
                
                // only 2 possible contexts, site or course
                if ($this->instance->pageid == SITEID) { // site context
-                       $currentcontext = $sitecontext;
+                       $currentcontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
+                       $canviewparticipants = has_capability('moodle/site:viewparticipants', $currentcontext);
                } else { // course context
                        $currentcontext = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
+                       $canviewparticipants = has_capability('moodle/course:viewparticipants', $currentcontext);
                }
                
-               if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
+               if (!$canviewparticipants) {
                        $this->context = '';
                        return $this->content;
                }
@@ -48,7 +49,7 @@ class block_participants extends block_list {
         }
 
         if ($this->instance->pageid != SITEID
-                || has_capability('moodle/course:viewparticipants', $sitecontext)) {
+                || $canviewparticipants) {
 
             $this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
                                       $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
index 6975043f94cccd7075f45f228f7b614791669cad..1dd45d9081c8c8a60a29583fc90431c3d3ffd44c 100644 (file)
@@ -199,6 +199,20 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
+        
+    'moodle/site:viewparticipants' => array(
+        
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'guest' => CAP_PREVENT,
+            'student' => CAP_PREVENT,
+            'teacher' => CAP_PREVENT,
+            'editingteacher' => CAP_ALLOW,
+            'coursecreator' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
     
     'moodle/site:viewreports' => array(