Permalink
Browse files

Merge branch 'w03_MDL-31127_m22_switchaccessinit' of git://github.com…

…/skodak/moodle into MOODLE_22_STABLE
  • Loading branch information...
2 parents 8838b16 + a5a993a commit b837c9e84dc23764913f3c5f7f72dc4c6944f0c2 @stronk7 stronk7 committed Jan 17, 2012
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/accesslib.php
View
@@ -1002,6 +1002,7 @@ function get_empty_accessdata() {
$accessdata['rdef_lcc'] = 0; // rdef_count during the last compression
$accessdata['loaded'] = array(); // loaded course contexts
$accessdata['time'] = time();
+ $accessdata['rsw'] = array();
return $accessdata;
}
@@ -1149,7 +1150,7 @@ function reload_all_capabilities() {
// copy switchroles
$sw = array();
- if (isset($USER->access['rsw'])) {
+ if (!empty($USER->access['rsw'])) {
$sw = $USER->access['rsw'];
}
@@ -3941,16 +3942,14 @@ function role_switch($roleid, context $context) {
//
// Note: it is not possible to switch to roles that do not have course:view
- // Add the switch RA
- if (!isset($USER->access['rsw'])) {
- $USER->access['rsw'] = array();
+ if (!isset($USER->access)) {
+ load_all_capabilities();
}
+
+ // Add the switch RA
if ($roleid == 0) {
unset($USER->access['rsw'][$context->path]);
- if (empty($USER->access['rsw'])) {
- unset($USER->access['rsw']);
- }
return true;
}

0 comments on commit b837c9e

Please sign in to comment.