It is a good idea, silly of me to remove it...
* (hint, use get_assignable_roles())
* - that the requested role is NOT $CFG->defaultuserroleid
*
+ * To "unswitch" pass 0 as the roleid.
+ *
* This function *will* modify $USER->access - beware
*
* @param integer $roleid
// To un-switch just unset($USER->access['rsw'][$path])
//
+ if ($roleid == 0) {
+ unset($USER->access['rsw'][$context->path]);
+ if (empty($USER->access['rsw'])) {
+ unset($USER->access['rsw']);
+ }
+ return true;
+ }
+
// Add the switch RA
if (!isset($USER->access['rsw'])) {
$USER->access['rsw'] = array();