Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip-MDL-29678-m22' of git://github.com/samhemelryk/mood…

…le into MOODLE_22_STABLE
  • Loading branch information...
commit fcc24148d6024063fa8b29e1a312f9dbf28f3c84 2 parents 729ef69 + 76fae9b
@stronk7 stronk7 authored
Showing with 10 additions and 3 deletions.
  1. +7 −0 lib/moodlelib.php
  2. +3 −3 lib/navigationlib.php
View
7 lib/moodlelib.php
@@ -2610,6 +2610,13 @@ function require_login($courseorid = NULL, $autologinguest = true, $cm = NULL, $
}
}
+ // If this is an AJAX request and $setwantsurltome is true then we need to override it and set it to false.
+ // Otherwise the AJAX request URL will be set to $SESSION->wantsurl and events such as self enrolment in the future
+ // risk leading the user back to the AJAX request URL.
+ if ($setwantsurltome && defined('AJAX_SCRIPT') && AJAX_SCRIPT) {
+ $setwantsurltome = false;
+ }
+
// If the user is not even logged in yet then make sure they are
if (!isloggedin()) {
if ($autologinguest and !empty($CFG->guestloginbutton) and !empty($CFG->autologinguests)) {
View
6 lib/navigationlib.php
@@ -2551,7 +2551,7 @@ public function initialise() {
break;
case self::TYPE_COURSE :
$course = $DB->get_record('course', array('id' => $this->instanceid), '*', MUST_EXIST);
- require_course_login($course);
+ require_course_login($course, true, null, false, true);
$this->page->set_context(get_context_instance(CONTEXT_COURSE, $course->id));
$coursenode = $this->add_course($course);
$this->add_course_essentials($coursenode, $course);
@@ -2565,7 +2565,7 @@ public function initialise() {
LEFT JOIN {course_sections} cs ON cs.course = c.id
WHERE cs.id = ?';
$course = $DB->get_record_sql($sql, array($this->instanceid), MUST_EXIST);
- require_course_login($course);
+ require_course_login($course, true, null, false, true);
$this->page->set_context(get_context_instance(CONTEXT_COURSE, $course->id));
$coursenode = $this->add_course($course);
$this->add_course_essentials($coursenode, $course);
@@ -2582,7 +2582,7 @@ public function initialise() {
$course = $DB->get_record_sql($sql, $params, MUST_EXIST);
$modinfo = get_fast_modinfo($course);
$cm = $modinfo->get_cm($this->instanceid);
- require_course_login($course, true, $cm);
+ require_course_login($course, true, $cm, false, true);
$this->page->set_context(get_context_instance(CONTEXT_MODULE, $cm->id));
$coursenode = $this->load_course($course);
if ($course->id == SITEID) {
Please sign in to comment.
Something went wrong with that request. Please try again.