MDL-51347 core_notes: check view notes capability by course context
authorSimey Lameze <simey@moodle.com>
Mon, 17 Oct 2016 08:07:16 +0000 (16:07 +0800)
committerMr. Jenkins (CiBoT) <cibot@moodle.org>
Thu, 10 Nov 2016 08:15:31 +0000 (16:15 +0800)
notes/index.php

index 8bff339..d9f9775 100644 (file)
@@ -185,12 +185,13 @@ if ($courseid != SITEID) {
             $ccontext = context_course::instance($c->id);
             $cfullname = format_string($c->fullname, true, array('context' => $ccontext));
             $header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $cfullname . '</a>';
-            if (has_capability('moodle/notes:manage', context_course::instance($c->id))) {
+            $viewcoursenotes = has_capability('moodle/notes:view', $ccontext);
+            if (has_capability('moodle/notes:manage', $ccontext)) {
                 $addid = $c->id;
             } else {
                 $addid = 0;
             }
-            note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
+            note_print_notes($header, $addid, $viewcoursenotes, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
         }
     }
 }