]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib/moodlelib: check $USER->access[rsw] for roleswitches
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:15:50 +0000 (07:15 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:15:50 +0000 (07:15 +0000)
lib/accesslib.php
lib/moodlelib.php

index 55c321f7d86eaec3ad0d3f6f1e259d1585f14015..0a9adeefa77a836907c94c634e4bbe8d3c7f856e 100755 (executable)
@@ -51,7 +51,7 @@
  *
  * accessdata ($ad) is a multidimensional array, holding
  * role assignments (RAs), role-capabilities-perm sets 
- * (Role Defs) and a list of courses we have loaded
+ * (role defs) and a list of courses we have loaded
  * data for.
  *
  * Things are keyed on "contextpaths" (the path field of 
@@ -1604,24 +1604,6 @@ function load_all_capabilities() {
 
         }
 
-        // handle role switching in courses
-        if (!empty($USER->switchrole)) {
-            foreach ($USER->switchrole as $contextid => $roleid) {
-                $context = get_context_instance_by_id($contextid);
-
-                // first prune context and any child contexts
-                $children = array_keys(get_child_contexts($context));
-                foreach ($children as $childid) {
-                    unset($USER->capabilities[$childid]);
-                }
-                unset($USER->capabilities[$contextid]);
-
-                // now merge all switched role caps in context and bellow
-                $swithccaps = get_role_context_caps($roleid, $context);
-                $USER->capabilities = merge_role_caps($USER->capabilities, $swithccaps);
-            }
-        }
-
         if (isset($USER->capabilities)) {
             $USER->capabilities = merge_role_caps($USER->capabilities, $defcaps);
         } else {
index 1f9b3b840b68e8710eae59644f6cc60ac5e23146..8cd475b25d5c501222fc0d768ffe07406da73b76 100644 (file)
@@ -1820,7 +1820,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null) {
                     $strloggedinasguest = get_string('loggedinasguest');
                     print_header_simple('', '',
                             build_navigation(array(array('name' => $strloggedinasguest, 'link' => null, 'type' => 'misc'))));
-                    if (empty($USER->switchrole[$context->id])) {  // Normal guest
+                    if (empty($USER->access['rsw'][$context->path])) {  // Normal guest
                         notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), "$CFG->wwwroot/login/index.php");
                     } else {
                         notify(get_string('guestsnotallowed', '', format_string($COURSE->fullname)));