MDL-46218 reshuffled access checks in blog and notes

This commit is contained in:
Andrew Davis
2014-07-10 11:25:23 +08:00
parent 92e7886965
commit 60770bb0a7
4 changed files with 47 additions and 50 deletions
+8 -9
View File
@@ -18,14 +18,17 @@ if (!$course = $DB->get_record('course', array('id'=>$note->courseid))) {
print_error('invalidcourseid');
}
// locate user information
if (!$user = $DB->get_record('user', array('id'=>$note->userid))) {
print_error('invaliduserid');
}
// require login to access notes
require_login($course);
if (empty($CFG->enablenotes)) {
print_error('notesdisabled', 'notes');
}
if (!$user = $DB->get_record('user', array('id' => $note->userid))) {
print_error('invaliduserid');
}
// locate context information
$context = context_course::instance($course->id);
@@ -34,10 +37,6 @@ if (!has_capability('moodle/notes:manage', $context)) {
print_error('nopermissiontodelete', 'notes');
}
if (empty($CFG->enablenotes)) {
print_error('notesdisabled', 'notes');
}
if (data_submitted() && confirm_sesskey()) {
//if data was submitted and is valid, then delete note
$returnurl = $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user=' . $note->userid;