Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…/skodak/moodle into MOODLE_22_STABLE
  • Loading branch information...
commit b837c9e84dc23764913f3c5f7f72dc4c6944f0c2 2 parents 8838b16 + a5a993a
Eloy Lafuente (stronk7) stronk7 authored

Showing 1 changed file with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. +6 7 lib/accesslib.php
13 lib/accesslib.php
@@ -1002,6 +1002,7 @@ function get_empty_accessdata() {
1002 1002 $accessdata['rdef_lcc'] = 0; // rdef_count during the last compression
1003 1003 $accessdata['loaded'] = array(); // loaded course contexts
1004 1004 $accessdata['time'] = time();
  1005 + $accessdata['rsw'] = array();
1005 1006
1006 1007 return $accessdata;
1007 1008 }
@@ -1149,7 +1150,7 @@ function reload_all_capabilities() {
1149 1150
1150 1151 // copy switchroles
1151 1152 $sw = array();
1152   - if (isset($USER->access['rsw'])) {
  1153 + if (!empty($USER->access['rsw'])) {
1153 1154 $sw = $USER->access['rsw'];
1154 1155 }
1155 1156
@@ -3941,16 +3942,14 @@ function role_switch($roleid, context $context) {
3941 3942 //
3942 3943 // Note: it is not possible to switch to roles that do not have course:view
3943 3944
3944   - // Add the switch RA
3945   - if (!isset($USER->access['rsw'])) {
3946   - $USER->access['rsw'] = array();
  3945 + if (!isset($USER->access)) {
  3946 + load_all_capabilities();
3947 3947 }
3948 3948
  3949 +
  3950 + // Add the switch RA
3949 3951 if ($roleid == 0) {
3950 3952 unset($USER->access['rsw'][$context->path]);
3951   - if (empty($USER->access['rsw'])) {
3952   - unset($USER->access['rsw']);
3953   - }
3954 3953 return true;
3955 3954 }
3956 3955

0 comments on commit b837c9e

Please sign in to comment.
Something went wrong with that request. Please try again.