From 8a58a8e17fccb089088296f709d1de51352c193e Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 29 Mar 2006 15:38:29 +0000 Subject: [PATCH] Starting the global COURSEID. 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 | 2 ++ lib/moodlelib.php | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/datalib.php b/lib/datalib.php index e4216328d2..2a605dffda 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -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 //////////////////////////////// diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 8475993f82..e6d8e059c9 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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; -- 2.39.5