Permalink
Browse files

Switch Roles MDL-11313 add a new config option to allow user to switc…

…h roles that they can't assign
  • Loading branch information...
1 parent ae5c373 commit 0c24a4523dbd34b4bd67897ee8ebfc0d95663a83 jerome committed Feb 12, 2009
Showing with 11 additions and 5 deletions.
  1. +2 −0 admin/settings/users.php
  2. +1 −1 course/view.php
  3. +2 −0 lang/en_utf8/admin.php
  4. +5 −3 lib/accesslib.php
  5. +1 −1 version.php
View
@@ -168,6 +168,8 @@
'mycourses' => get_string('mycourses'))));
}
+ $temp->add(new admin_setting_configcheckbox('allowuserswitchrolestheycantassign', get_string('allowuserswitchrolestheycantassign', 'admin'), get_string('configallowuserswitchrolestheycantassign', 'admin'), 0));
+
$ADMIN->add('roles', $temp);
} // end of speedup
View
@@ -57,7 +57,7 @@
has_capability('moodle/role:switchroles', $context)) {
// is this role assignable in this context?
// inquiring minds want to know...
- $aroles = get_assignable_roles($context);
+ $aroles = get_assignable_roles_for_switchrole($context);
if (is_array($aroles) && isset($aroles[$switchrole])) {
role_switch($switchrole, $context);
// Double check that this role is allowed here
View
@@ -13,6 +13,7 @@
$string['allowuserblockhiding'] = 'Allow users to hide blocks';
$string['allowusermailcharset'] = 'Allow user to select character set';
$string['allowuserthemes'] = 'Allow user themes';
+$string['allowuserswitchrolestheycantassign'] = 'Allow users to switch to roles that they can\'t assign';
$string['allowvisiblecoursesinhiddencategories'] = 'Allow visible courses in hidden categories';
$string['antivirus'] = 'Anti-Virus';
$string['appearance'] = 'Appearance';
@@ -254,6 +255,7 @@
$string['configtimezone'] = 'You can set the default timezone here. This is the only the DEFAULT timezone for displaying dates - each user can override this by setting their own in their profile. \"Server time\" here will make Moodle default to the server\'s operating system setting, but \"Server time\" in the user profile will make the user default to this timezone setting. Cronjobs that depend on a time of day to run will use this timezone.';
$string['configunzip'] = 'Indicate the location of your unzip program (Unix only, optional). If specified, this will be used to unpack zip archives on the server. If you leave this blank, then Moodle will use internal routines.';
$string['configusetags'] = 'Should tags functionality across the site be enabled?';
+$string['configallowuserswitchrolestheycantassign'] = 'Allow users to switch to roles that they can\'t assign';
$string['configvariables'] = 'Variables';
$string['configverifychangedemail'] = 'Enables verification of changed email addresses using allowed and denied email domains settings. If this setting is disabled the domains are enforced only when creating new users.';
$string['configwarning'] = 'Be careful modifying these settings - strange values could cause problems.';
View
@@ -4242,9 +4242,11 @@ function get_assignable_roles($context, $field='name', $rolenamedisplay=ROLENAME
function get_assignable_roles_for_switchrole($context, $field='name', $rolenamedisplay=ROLENAME_ALIAS) {
global $USER, $CFG;
- if (!has_capability('moodle/role:assign', $context)) {
- return array();
- }
+ if (!$CFG->allowuserswitchrolestheycantassign) { //config implemented for MDL-11313
+ if (!has_capability('moodle/role:assign', $context)) {
+ return array();
+ }
+ }
$parents = get_parent_contexts($context);
$parents[] = $context->id;
View
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007101540; // YYYYMMDD = date of the 1.9 branch (don't change)
+ $version = 2007101541; // YYYYMMDD = date of the 1.9 branch (don't change)
// X = release number 1.9.[0,1,2,3,4,5...]
// Y.YY = micro-increments between releases

0 comments on commit 0c24a45

Please sign in to comment.