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

This commit is contained in:
Andrew Nicols
2019-09-02 17:04:35 +02:00
committed by Jenkins
parent 8cb4578de8
commit ed080a580f
2 changed files with 50 additions and 1 deletions
+5 -1
View File
@@ -166,7 +166,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.