/** * A convenience function to completely load all the capabilities * for the current user. It is called from has_capability() and functions change permissions. * * Call it only _after_ you've setup $USER and called check_enrolment_plugins(); * @see check_enrolment_plugins() * * @private * @return void */ function load_all_capabilities() { global $USER; // roles not installed yet - we are in the middle of installation if (during_initial_install()) { return; } if (!isset($USER->id)) { // this should not happen $USER->id = 0; } unset($USER->access); $USER->access = get_user_accessdata($USER->id); // deduplicate the overrides to minimize session size dedupe_user_access(); // Clear to force a refresh unset($USER->mycourses); // init/reset internal enrol caches - active course enrolments and temp access $USER->enrol = array('enrolled' => array(), 'tempguest' => array()); }
/** * A convenience function to completely load all the capabilities * for the current user. It is called from has_capability() and functions change permissions. * * Call it only _after_ you've setup $USER and called check_enrolment_plugins(); * @see check_enrolment_plugins() * * @private * @return void */ function load_all_capabilities() { global $USER; // roles not installed yet - we are in the middle of installation if (during_initial_install()) { return; } if (!isset($USER->id)) { // this should not happen $USER->id = 0; } unset($USER->access); $USER->access = get_user_accessdata($USER->id); // deduplicate the overrides to minimize session size dedupe_user_access(); // Clear to force a refresh unset($USER->mycourses); unset($USER->enrol); }