Merge branch 'MDL-29892_overview_hidden' of git://github.com/andyjdavis/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 8 Feb 2012 02:38:36 +0000 (03:38 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 8 Feb 2012 02:38:36 +0000 (03:38 +0100)
grade/report/overview/lib.php

index cf8b757..b610817 100644 (file)
@@ -119,7 +119,14 @@ class grade_report_overview extends grade_report {
                 if (!$course->showgrades) {
                     continue;
                 }
+
                 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
+                if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
+                    // The course is hidden and the user isn't allowed to see it
+                    continue;
+                }
+
                 $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
                 $courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $courseshortname);
                 $canviewhidden = has_capability('moodle/grade:viewhidden', $coursecontext);