MDL-54035 accesslib: Check if the user can switch role before switching

This commit is contained in:
David Monllao
2018-09-26 13:03:08 +02:00
parent 0e79528704
commit e8ce6ca306
+3 -1
View File
@@ -1019,7 +1019,9 @@ function reload_all_capabilities() {
foreach ($sw as $path => $roleid) {
if ($record = $DB->get_record('context', array('path'=>$path))) {
$context = context::instance_by_id($record->id);
role_switch($roleid, $context);
if (has_capability('moodle/role:switchroles', $context)) {
role_switch($roleid, $context);
}
}
}
}