From 48c79eb3e96ba9e1fe163b579e9b5d8dc2c3d35f Mon Sep 17 00:00:00 2001 From: sam marshall Date: Fri, 1 Aug 2014 17:39:51 +0100 Subject: [PATCH] MDL-44725 Availability: Replace groupmembersonly - login (5) Remove groupmembersonly option from require_login. NOTE: This code, and another branch (both related to login when accessing activities on the site course), are not actually necessary because there is code above which already checks $cm->uservisible. NOTE: You can see this change more simply by doing git diff --ignore-space-change; indent was altered. --- lib/moodlelib.php | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 91faf990487..c57d8ab09c9 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3253,37 +3253,28 @@ function require_course_login($courseorid, $autologinguest = true, $cm = null, $ } else if ($issite) { // Login for SITE not required. - if ($cm and empty($cm->visible)) { - // Hidden activities are not accessible without login. - require_login($courseorid, $autologinguest, $cm, $setwantsurltome, $preventredirect); - } else if ($cm and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) { - // Not-logged-in users do not have any group membership. - require_login($courseorid, $autologinguest, $cm, $setwantsurltome, $preventredirect); - } 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) { - if ($cm->course != $course->id) { - throw new coding_exception('course and cm parameters in require_course_login() call do not match!!'); - } - $PAGE->set_cm($cm, $course); - $PAGE->set_pagelayout('incourse'); - } else { - $PAGE->set_course($course); - } + // 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 { - // If $PAGE->course, and hence $PAGE->context, have not already been set up properly, set them up now. - $PAGE->set_course($PAGE->course); + $course = clone $SITE; } - // TODO: verify conditional activities here. - user_accesstime_log(SITEID); - return; + if ($cm) { + if ($cm->course != $course->id) { + throw new coding_exception('course and cm parameters in require_course_login() call do not match!!'); + } + $PAGE->set_cm($cm, $course); + $PAGE->set_pagelayout('incourse'); + } 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); } + user_accesstime_log(SITEID); + return; } else { // Course login always required.