]> git.mjollnir.org Git - moodle.git/commitdiff
Make $COURSE a full object for later use
authormoodler <moodler>
Mon, 29 May 2006 07:31:22 +0000 (07:31 +0000)
committermoodler <moodler>
Mon, 29 May 2006 07:31:22 +0000 (07:31 +0000)
lib/moodlelib.php
lib/setup.php

index 92994ca52517f43c7d501e07bae29f0b4053fcf3..ff8d5aab13bd56789b39f50583b6940000d008c7 100644 (file)
@@ -1505,9 +1505,12 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) {
 
     global $CFG, $SESSION, $USER, $COURSE, $FULLME, $MoodleSession;
 
-    // Redefine global $COURSE, this is a new idea in 1.6 Beta and not to be relied on yet
-    if ($courseid) {
-        $COURSE->id = $courseid;
+    // Redefine global $COURSE if we can
+    global $course;  // We use the global hack once here so it doesn't need to be used again
+    if (is_object($course)) {
+        $COURSE = clone($course);
+    } else if ($courseid) {
+        $COURSE = get_record('course', 'id', $courseid);
     }
 
     // First check that the user is logged in to the site.
index 07004aea8b6616e7d0a58de7a429a60981c9a8f8..ff88d84fdca654a34a8a9c6a7b22079f34d747c7 100644 (file)
@@ -233,7 +233,7 @@ global $HTTPSPAGEREQUIRED;
         define('COURSEID', 1);
     }
 /// And the 'default' course
-    $COURSE->id = SITEID;   // For now.  This will usually get reset later in require_login() etc.
+    $COURSE = clone($SITE);   // For now.  This will usually get reset later in require_login() etc.
 
 
 /// Set a default enrolment configuration (see bug 1598)