]> git.mjollnir.org Git - moodle.git/commitdiff
Starting the global COURSEID.
authormoodler <moodler>
Wed, 29 Mar 2006 15:38:29 +0000 (15:38 +0000)
committermoodler <moodler>
Wed, 29 Mar 2006 15:38:29 +0000 (15:38 +0000)
require_login seems to be the best place to capture this, however
I'm sure there are a few little places where it won't work.

We need to hunt these places down and fix them, because I would
like to rely on COURSEID and remove all the "global $course" hacks
that are floating around.

Probably later we need the full object $COURSE as well (to match $SITE)

lib/datalib.php
lib/moodlelib.php

index e4216328d2193d5f11e492b90741259029370908..2a605dffda50256ae59d5c06cb2d65f3d14d2289 100644 (file)
@@ -20,11 +20,13 @@ if ($SITE = get_site()) {
      * If $SITE global from {@link get_site()} is set then SITEID to $SITE->id, otherwise set to 1.
      */
     define('SITEID', $SITE->id);
+    define('COURSEID', SITEID);   // For now.  This will usually get reset later in require_login() etc.
 } else {
     /**
      * @ignore
      */
     define('SITEID', 1);
+    define('COURSEID', 1);
 }
 
 /// FUNCTIONS FOR DATABASE HANDLING  ////////////////////////////////
index 8475993f827025b4390905ac792db3520f70d691..e6d8e059c9d0c885a5f6dbdc65438023bf278e60 100644 (file)
@@ -1495,6 +1495,7 @@ function require_logout() {
  * @uses $USER
  * @uses $FULLME
  * @uses SITEID
+ * @uses COURSEID
  * @uses $MoodleSession
  * @param int $courseid id of the course
  * @param bool $autologinguest
@@ -1504,6 +1505,12 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) {
 
     global $CFG, $SESSION, $USER, $FULLME, $MoodleSession;
 
+    // Redefine global COURSEID, this is a new idea in 1.6 Beta and not to be relied on yet
+
+    if ($courseid) {
+        define('COURSEID', $courseid);
+    }
+
     // First check that the user is logged in to the site.
     if (! (isset($USER->loggedin) and $USER->confirmed and ($USER->site == $CFG->wwwroot)) ) { // They're not
         $SESSION->wantsurl = $FULLME;