}
}
if ($cm) {
- $PAGE->set_cm($cm, $course);
+ $PAGE->set_cm($cm, $course); // set's up global $COURSE
$PAGE->set_pagelayout('incourse');
} else {
- $PAGE->set_course($course);
+ $PAGE->set_course($course); // set's up global $COURSE
}
} else {
- // If $PAGE->course, and hence $PAGE->context, have not already been set
- // up properly, set them up now.
- $PAGE->set_course($PAGE->course);
+ // do not touch global $COURSE via $PAGE->set_course() !!
}
/// If the user is not even logged in yet then make sure they are
}
}
-// We used to call moodle_setlocale() and theme_setup() here, even though they
-// would be called again from require_login or $PAGE->set_course. As an experiment
-// I am going to try removing those calls. With luck it will help us find and
-// fix a few bugs where scripts do not initialise things properly, without causing
-// too much grief.
+// Set the default site locale, a lot of the stuff may depend on this
+// it is definitely too late to call this first in require_login()!
+moodle_setlocale();
if (!empty($CFG->debugvalidators) and !empty($CFG->guestloginbutton)) {
if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') { // Temporary measure to help with XHTML validation