MDL-61115: mod_lesson: Check if the teacher can access the override

This commit is contained in:
Shamim Rezaie 2019-07-02 03:40:42 +10:00 committed by Eloy Lafuente (stronk7)
parent b392686a65
commit eb70df6f4b
2 changed files with 20 additions and 0 deletions

View File

@ -49,6 +49,16 @@ require_login($course, false, $cm);
// Check the user has the required capabilities to modify an override.
require_capability('mod/lesson:manageoverrides', $context);
if ($override->groupid) {
if (!groups_group_visible($override->groupid, $course, $cm)) {
print_error('invalidoverrideid', 'lesson');
}
} else {
if (!groups_user_groups_visible($course, $override->userid, $cm)) {
print_error('invalidoverrideid', 'lesson');
}
}
$url = new moodle_url('/mod/lesson/overridedelete.php', array('id' => $override->id));
$confirmurl = new moodle_url($url, array('id' => $override->id, 'confirm' => 1));
$cancelurl = new moodle_url('/mod/lesson/overrides.php', array('cmid' => $cm->id));

View File

@ -76,6 +76,16 @@ require_capability('mod/lesson:manageoverrides', $context);
if ($overrideid) {
// Editing an override.
$data = clone $override;
if ($override->groupid) {
if (!groups_group_visible($override->groupid, $course, $cm)) {
print_error('invalidoverrideid', 'lesson');
}
} else {
if (!groups_user_groups_visible($course, $override->userid, $cm)) {
print_error('invalidoverrideid', 'lesson');
}
}
} else {
// Creating a new override.
$data = new stdClass();