mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-14183 guest type role not allowed in defaultuserroleid anymore, because it was causing trouble in many places; admins must choose another role if guest role detected in this setting; merged from MOODLE_19_STABLE
This commit is contained in:
parent
d4e5675c00
commit
ab37dc6031
3 changed files with 27 additions and 3 deletions
|
@ -68,6 +68,22 @@ function xmldb_main_upgrade($oldversion=0) {
|
|||
upgrade_main_savepoint($result, 2008050700);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2008051200) {
|
||||
// if guest role used as default user role unset it and force admin to choose new setting
|
||||
if (!empty($CFG->defaultuserroleid)) {
|
||||
if ($role = get_record('role', 'id', $CFG->defaultuserroleid)) {
|
||||
if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
|
||||
if (isset($guestroles[$role->id])) {
|
||||
set_config('defaultuserroleid', null);
|
||||
notify('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set_config('defaultuserroleid', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue