]> git.mjollnir.org Git - moodle.git/commitdiff
Fix to ignore hidden courses when using switchrole in a course MDL-6841
authormoodler <moodler>
Thu, 5 Oct 2006 08:41:06 +0000 (08:41 +0000)
committermoodler <moodler>
Thu, 5 Oct 2006 08:41:06 +0000 (08:41 +0000)
lib/moodlelib.php

index 97faff1093e35fcf9f24aa160003c530ea6ef66d..16fabf8d0c2f594a663b36aeba62c934a083454c 100644 (file)
@@ -1592,19 +1592,21 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) {
             }
             return;
         }
+
  
     /// If the whole course is hidden from us then we can stop now
 
-        if (!($course->visible && course_parent_visible($course)) &&
-               !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id)) ){
-            print_header();
-            notice(get_string('coursehidden'), $CFG->wwwroot .'/');
-        }    
-        
         if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
             print_error('nocontext');
         }
 
+        if (empty($USER->switchrole[$context->id]) &&
+            !($course->visible && course_parent_visible($course)) &&
+               !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id)) ){
+            print_header_simple();
+            notice(get_string('coursehidden'), $CFG->wwwroot .'/');
+        }    
+        
     /// If the user is a guest then treat them according to the course policy about guests
 
         if (has_capability('moodle/legacy:guest', $context, NULL, false)) {