MDL-37483 improve require_login redirect when activity not accessible
authorPetr Škoda <commits@skodak.org>
Sun, 13 Jan 2013 10:33:08 +0000 (11:33 +0100)
committerPetr Škoda <commits@skodak.org>
Sun, 13 Jan 2013 10:37:14 +0000 (11:37 +0100)
lib/moodlelib.php

index d27391a..c7d6621 100644 (file)
@@ -3082,7 +3082,12 @@ function require_login($courseorid = NULL, $autologinguest = true, $cm = NULL, $
         if ($preventredirect) {
             throw new require_login_exception('Activity is hidden');
         }
-        redirect($CFG->wwwroot, get_string('activityiscurrentlyhidden'));
+        if ($course->id != SITEID) {
+            $url = new moodle_url('/course/view.php', array('id'=>$course->id));
+        } else {
+            $url = new moodle_url('/');
+        }
+        redirect($url, get_string('activityiscurrentlyhidden'));
     }
 
     // Finally access granted, update lastaccess times