mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 22:50:19 +01:00
MDL-48804 core: do not set current course until login validated
This commit is contained in:
parent
bd3b68c8a7
commit
1edd3d6fbf
@ -2853,10 +2853,6 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$cm = $modinfo->get_cm($cm->id);
|
||||
}
|
||||
$PAGE->set_cm($cm, $course); // Set's up global $COURSE.
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
} else {
|
||||
$PAGE->set_course($course); // Set's up global $COURSE.
|
||||
}
|
||||
} else {
|
||||
// Do not touch global $COURSE via $PAGE->set_course(),
|
||||
@ -2960,6 +2956,13 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
|
||||
|
||||
// Do not bother admins with any formalities.
|
||||
if (is_siteadmin()) {
|
||||
// Set the global $COURSE.
|
||||
if ($cm) {
|
||||
$PAGE->set_cm($cm, $course);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
} else if (!empty($courseorid)) {
|
||||
$PAGE->set_course($course);
|
||||
}
|
||||
// Set accesstime or the user will appear offline which messes up messaging.
|
||||
user_accesstime_log($course->id);
|
||||
return;
|
||||
@ -3017,6 +3020,7 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
|
||||
if ($preventredirect) {
|
||||
throw new require_login_exception('Course is hidden');
|
||||
}
|
||||
$PAGE->set_context(null);
|
||||
// We need to override the navigation URL as the course won't have been added to the navigation and thus
|
||||
// the navigation will mess up when trying to find it.
|
||||
navigation_node::override_active_url(new moodle_url('/'));
|
||||
@ -3037,6 +3041,7 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
|
||||
if ($preventredirect) {
|
||||
throw new require_login_exception('Invalid course login-as access');
|
||||
}
|
||||
$PAGE->set_context(null);
|
||||
echo $OUTPUT->header();
|
||||
notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/');
|
||||
}
|
||||
@ -3151,6 +3156,14 @@ 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);
|
||||
}
|
||||
|
@ -370,7 +370,6 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('requireloginerror', $e->errorcode);
|
||||
}
|
||||
$this->assertDebuggingCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user