MDL-51347 core_notes: check view notes capability by course context

This commit is contained in:
Simey Lameze 2016-10-17 16:07:16 +08:00 committed by Mr. Jenkins (CiBoT)
parent cf0b9432d8
commit face152176

View 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);
}
}
}