Skip to content

Commit

Permalink
MDL-61115: mod_lesson: Check if the teacher can access the override
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies authored and stronk7 committed Jul 3, 2019
1 parent 1aa9422 commit 5e9dd95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mod/lesson/overridedelete.php
Expand Up @@ -49,6 +49,16 @@
// 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));
Expand Down
10 changes: 10 additions & 0 deletions mod/lesson/overrideedit.php
Expand Up @@ -76,6 +76,16 @@
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();
Expand Down

0 comments on commit 5e9dd95

Please sign in to comment.