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)
This commit is contained in:
moodler
2006-03-29 15:38:29 +00:00
parent 688e209c5c
commit 8a58a8e17f
2 changed files with 9 additions and 0 deletions
+2
View 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 ////////////////////////////////
+7
View 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;