From: Sam Hemelryk Date: Thu, 10 Dec 2009 01:57:01 +0000 (+0000) Subject: moodlelib MDL-21060 Editing require_course_login to properly set page vars for the... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=862940c0337d74d48822f0aea2db1a117e99e2a4;p=moodle.git moodlelib MDL-21060 Editing require_course_login to properly set page vars for the front page course --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 8ecf1953ed..e11b6f51b2 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2357,7 +2357,7 @@ function require_logout() { * in order to keep redirects working properly. MDL-14495 */ function require_course_login($courseorid, $autologinguest=true, $cm=null, $setwantsurltome=true) { - global $CFG; + global $CFG, $PAGE, $SITE; if (!empty($CFG->forcelogin)) { // login required for both SITE and courses require_login($courseorid, $autologinguest, $cm, $setwantsurltome); @@ -2376,6 +2376,24 @@ function require_course_login($courseorid, $autologinguest=true, $cm=null, $setw // not-logged-in users do not have any group membership require_login($courseorid, $autologinguest, $cm, $setwantsurltome); } else { + // We still need to instatiate PAGE vars properly so that things + // that rely on it like navigation function correctly. + if (!empty($courseorid)) { + if (is_object($courseorid)) { + $course = $courseorid; + } else { + $course = clone($SITE); + } + if ($cm) { + $PAGE->set_cm($cm, $course); + } else { + $PAGE->set_course($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); + } //TODO: verify conditional activities here user_accesstime_log(SITEID); return;