From 51fef1de359439c79fa98bd9ebec19077e66cb57 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Mon, 9 Mar 2015 11:26:18 +0800 Subject: [PATCH] MDL-49418 core: partial revert of MDL-48804 this is a quick fix for the issue 'Course module with two or more availability restrictions is not accessible' MDL-49434 is created to deal with the renderer access inside availability check --- lib/moodlelib.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 2747982b6ac..7d8ea2fb794 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3143,6 +3143,15 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $ } } + // Set the global $COURSE. + // TODO MDL-49434: setting current course/cm should be after the check $cm->uservisible . + if ($cm) { + $PAGE->set_cm($cm, $course); + $PAGE->set_pagelayout('incourse'); + } else if (!empty($courseorid)) { + $PAGE->set_course($course); + } + // Check visibility of activity to current user; includes visible flag, conditional availability, etc. if ($cm && !$cm->uservisible) { if ($preventredirect) { @@ -3156,14 +3165,6 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $ redirect($url, get_string('activityiscurrentlyhidden')); } - // Set the global $COURSE. - if ($cm) { - $PAGE->set_cm($cm, $course); - $PAGE->set_pagelayout('incourse'); - } else if (!empty($courseorid)) { - $PAGE->set_course($course); - } - // Finally access granted, update lastaccess times. user_accesstime_log($course->id); } -- 2.43.0