Skip to content

Commit

Permalink
Merge branch 'wip-MDL-29678-m22' of git://github.com/samhemelryk/mood…
Browse files Browse the repository at this point in the history
…le into MOODLE_22_STABLE
  • Loading branch information
stronk7 committed Apr 3, 2012
2 parents 729ef69 + 76fae9b commit fcc2414
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit fcc2414

Please sign in to comment.