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
|
@ -108,13 +108,21 @@ if ($hassiteconfig
|
||||||
set_config('creatornewroleid', 0);
|
set_config('creatornewroleid', 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
|
||||||
|
$guestroles = array();
|
||||||
|
}
|
||||||
// we must not use assignable roles here:
|
// we must not use assignable roles here:
|
||||||
// 1/ unsetting roles as assignable for admin might bork the settings!
|
// 1/ unsetting roles as assignable for admin might bork the settings!
|
||||||
// 2/ default user role should not be assignable anyway
|
// 2/ default user role should not be assignable anyway
|
||||||
$allroles = array();
|
$allroles = array();
|
||||||
|
$nonguestroles = array();
|
||||||
if ($roles = get_all_roles()) {
|
if ($roles = get_all_roles()) {
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
$allroles[$role->id] = strip_tags(format_string($role->name, true));
|
$rolename = strip_tags(format_string($role->name, true));
|
||||||
|
$allroles[$role->id] = $rolename;
|
||||||
|
if (!isset($guestroles[$role->id])) {
|
||||||
|
$nonguestroles[$role->id] = $rolename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +131,7 @@ if ($hassiteconfig
|
||||||
$temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
|
$temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
|
||||||
get_string('configguestroleid', 'admin'), $guestrole->id, $allroles));
|
get_string('configguestroleid', 'admin'), $guestrole->id, $allroles));
|
||||||
$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
|
$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
|
||||||
get_string('configdefaultuserroleid', 'admin'), $userrole->id, $allroles));
|
get_string('configdefaultuserroleid', 'admin'), $userrole->id, $nonguestroles)); // guest role here breaks a lot of stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
|
$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
|
||||||
|
|
|
@ -68,6 +68,22 @@ function xmldb_main_upgrade($oldversion=0) {
|
||||||
upgrade_main_savepoint($result, 2008050700);
|
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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// This is compared against the values stored in the database to determine
|
// This is compared against the values stored in the database to determine
|
||||||
// whether upgrades should be performed (see lib/db/*.php)
|
// whether upgrades should be performed (see lib/db/*.php)
|
||||||
|
|
||||||
$version = 2008050700; // YYYYMMDD = date of the last version bump
|
$version = 2008051200; // YYYYMMDD = date of the last version bump
|
||||||
// XX = daily increments
|
// XX = daily increments
|
||||||
|
|
||||||
$release = '2.0 dev (Build: 20080512)'; // Human-friendly version name
|
$release = '2.0 dev (Build: 20080512)'; // Human-friendly version name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue