]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12501 - Logic for including 'Grades' link in admin block is different for the...
authortjhunt <tjhunt>
Fri, 7 Dec 2007 16:58:07 +0000 (16:58 +0000)
committertjhunt <tjhunt>
Fri, 7 Dec 2007 16:58:07 +0000 (16:58 +0000)
blocks/admin/block_admin.php

index bd963d86e995cb1b051af6f512926f2032decc6e..19b03475d3900c5dcc90859518da4381c08a3e0a 100644 (file)
@@ -70,10 +70,20 @@ class block_admin extends block_list {
         }
 
     /// View course grades (or just your own grades, same link)
-        if ((has_capability('moodle/grade:viewall', $context) or
-            (has_capability('moodle/grade:view', $context) && $course->showgrades)) && ($course->id!==SITEID)) {
-            $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/report/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
-            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" class="icon" alt="" />';
+    /// find all accessible reports
+        if ($course->id!==SITEID) {
+            if ($reports = get_list_of_plugins('grade/report', 'CVS')) {     // Get all installed reports
+                foreach ($reports as $key => $plugin) {                      // Remove ones we can't see
+                    if (!has_capability('gradereport/'.$plugin.':view', $context)) {
+                        unset($reports[$key]);
+                    }
+                }
+            }
+
+            if (!empty($reports)) {
+                $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/report/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
+                $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" class="icon" alt="" />';
+            }
         }
 
     /// Course outcomes (to help give it more prominence because it's important)