Skip to content

Commit

Permalink
Merge branch 'w03_MDL-31127_m22_switchaccessinit' of git://github.com…
Browse files Browse the repository at this point in the history
…/skodak/moodle into MOODLE_22_STABLE
  • Loading branch information
stronk7 committed Jan 17, 2012
2 parents 8838b16 + a5a993a commit b837c9e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/accesslib.php
Expand Up @@ -1002,6 +1002,7 @@ function get_empty_accessdata() {
$accessdata['rdef_lcc'] = 0; // rdef_count during the last compression $accessdata['rdef_lcc'] = 0; // rdef_count during the last compression
$accessdata['loaded'] = array(); // loaded course contexts $accessdata['loaded'] = array(); // loaded course contexts
$accessdata['time'] = time(); $accessdata['time'] = time();
$accessdata['rsw'] = array();


return $accessdata; return $accessdata;
} }
Expand Down Expand Up @@ -1149,7 +1150,7 @@ function reload_all_capabilities() {


// copy switchroles // copy switchroles
$sw = array(); $sw = array();
if (isset($USER->access['rsw'])) { if (!empty($USER->access['rsw'])) {
$sw = $USER->access['rsw']; $sw = $USER->access['rsw'];
} }


Expand Down Expand Up @@ -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 // Note: it is not possible to switch to roles that do not have course:view


// Add the switch RA if (!isset($USER->access)) {
if (!isset($USER->access['rsw'])) { load_all_capabilities();
$USER->access['rsw'] = array();
} }



// Add the switch RA
if ($roleid == 0) { if ($roleid == 0) {
unset($USER->access['rsw'][$context->path]); unset($USER->access['rsw'][$context->path]);
if (empty($USER->access['rsw'])) {
unset($USER->access['rsw']);
}
return true; return true;
} }


Expand Down

0 comments on commit b837c9e

Please sign in to comment.