]> git.mjollnir.org Git - moodle.git/commitdiff
Changed logic slightly in switchrole_form
authormoodler <moodler>
Thu, 21 Sep 2006 14:04:32 +0000 (14:04 +0000)
committermoodler <moodler>
Thu, 21 Sep 2006 14:04:32 +0000 (14:04 +0000)
lib/weblib.php

index f918adca3da9e2ff9ef893450e90a630b83702e0..313a5671892644091a238f9188114e7c28e658af 100644 (file)
@@ -3729,27 +3729,25 @@ function switchroles_form($courseid) {
         return '';
     }
 
-    if (has_capability('moodle/role:switchroles', $context)) {
-        if (empty($USER->switchrole)) {   // Print a menu
+    if (empty($USER->switchrole)) {   // Try to print a menu
+        if (has_capability('moodle/role:switchroles', $context)) {
             if (!$roles = get_assignable_roles($context)) {
                 return '';   // Nothing to show!
             }
-
             return popup_form($CFG->wwwroot.'/course/view.php?id='.$courseid.'&sesskey='.sesskey().'&switchrole=', 
                               $roles, 'switchrole', '', get_string('switchroleto'), 'switchrole', '', true);
-        
-        } else {  // Just a button to return to normal
-            $options = array();
-            $options['id'] = $courseid;
-            $options['sesskey'] = sesskey();
-            $options['switchrole'] = 0;
-
-            return print_single_button($CFG->wwwroot.'/course/view.php', $options,  
-                                       get_string('switchrolereturn'), 'post', '_self', true);
+        } else {
+            return '';
         }
-    }
+    } else {  // Just a button to return to normal
+        $options = array();
+        $options['id'] = $courseid;
+        $options['sesskey'] = sesskey();
+        $options['switchrole'] = 0;
 
-    return '';
+        return print_single_button($CFG->wwwroot.'/course/view.php', $options,  
+                                   get_string('switchrolereturn'), 'post', '_self', true);
+    }
 }