MDL-69093 enrol_manual: added check for allowed roles a user can assign

This commit is contained in:
Víctor Déniz Falcón 2020-07-01 09:37:46 +01:00 committed by Jenkins
parent 877a3f70d0
commit d07fb8b9e8

View file

@ -100,6 +100,13 @@ switch ($action) {
if (empty($roleid)) { if (empty($roleid)) {
$roleid = null; $roleid = null;
} else {
if (!has_capability('moodle/role:assign', $context)) {
throw new enrol_ajax_exception('assignnotpermitted');
}
if (!array_key_exists($roleid, get_assignable_roles($context, ROLENAME_ALIAS, false))) {
throw new enrol_ajax_exception('invalidrole');
}
} }
if (empty($startdate)) { if (empty($startdate)) {