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)
* 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 ////////////////////////////////
* @uses $USER
* @uses $FULLME
* @uses SITEID
+ * @uses COURSEID
* @uses $MoodleSession
* @param int $courseid id of the course
* @param bool $autologinguest
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;