MDL-66181 course: Only assign roles that the user is allowed to assign

This commit is contained in:
Andrew Nicols
2019-08-30 07:21:39 +02:00
committed by Jenkins
parent d33ae6c0cc
commit 86cbf2a643
2 changed files with 50 additions and 1 deletions
+5 -1
View File
@@ -161,7 +161,11 @@ if ($editform->is_cancelled()) {
if (!empty($CFG->creatornewroleid) and !is_viewing($context, NULL, 'moodle/role:assign') and !is_enrolled($context, NULL, 'moodle/role:assign')) {
// Deal with course creators - enrol them internally with default role.
enrol_try_internal_enrol($course->id, $USER->id, $CFG->creatornewroleid);
if (user_can_assign($context, $CFG->creatornewroleid)) {
enrol_try_internal_enrol($course->id, $USER->id, $CFG->creatornewroleid);
} else {
enrol_try_internal_enrol($course->id, $USER->id);
}
}
// The URL to take them to if they chose save and display.