From 9ce2fe53cb6630a1b72247c1f5801b34559871d3 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 7 Dec 2007 16:58:07 +0000 Subject: [PATCH] MDL-12501 - Logic for including 'Grades' link in admin block is different for the logic in grade/report/index.php. Merged from MOODLE_19_STABLE. --- blocks/admin/block_admin.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/blocks/admin/block_admin.php b/blocks/admin/block_admin.php index bd963d86e99..19b03475d39 100644 --- a/blocks/admin/block_admin.php +++ b/blocks/admin/block_admin.php @@ -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[]=''.get_string('grades').''; - $this->content->icons[]=''; + /// 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[]=''.get_string('grades').''; + $this->content->icons[]=''; + } } /// Course outcomes (to help give it more prominence because it's important)