Skip to content

Commit

Permalink
Merge branch 'wip-MDL-27809-master-r7' of git://github.com/samhemelry…
Browse files Browse the repository at this point in the history
…k/moodle
  • Loading branch information
stronk7 committed Jun 27, 2011
2 parents 29e2d0a + 3992a46 commit f83776f
Show file tree
Hide file tree
Showing 3 changed files with 426 additions and 354 deletions.
28 changes: 16 additions & 12 deletions course/switchrole.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
require_once('../config.php');
require_once($CFG->dirroot.'/course/lib.php');

$id = required_param('id', PARAM_INT);
$switchrole = optional_param('switchrole',-1, PARAM_INT);
$returnurlkey = optional_param('returnurl', false, PARAM_INT);
$id = required_param('id', PARAM_INT);
$switchrole = optional_param('switchrole',-1, PARAM_INT);
$returnurl = optional_param('returnurl', false, PARAM_URL);

$PAGE->set_url('/course/switchrole.php', array('id'=>$id));

Expand Down Expand Up @@ -69,17 +69,21 @@
}
}

$returnurl = false;
if ($returnurlkey && !empty($SESSION->returnurl) && strpos($SESSION->returnurl, 'moodle_url')!==false) {
$returnurl = @unserialize($SESSION->returnurl);
if (!($returnurl instanceof moodle_url)) {
$returnurl = false;
// TODO: Using SESSION->returnurl is deprecated and should be removed in the future.
// Till then this code remains to support any external applications calling this script.
if (!empty($returnurl) && is_numeric($returnurl)) {
$returnurl = false;
if (!empty($SESSION->returnurl) && strpos($SESSION->returnurl, 'moodle_url')!==false) {
debugging('Code calling switchrole should be passing a URL as a param.', DEBUG_DEVELOPER);
$returnurl = @unserialize($SESSION->returnurl);
if (!($returnurl instanceof moodle_url)) {
$returnurl = false;
}
}
unset($SESSION->returnurl);
}

if ($returnurl===false) {
$returnurl = new moodle_url('/course/view.php', array('id'=>$course->id));
if ($returnurl === false) {
$returnurl = new moodle_url('/course/view.php', array('id' => $course->id));
}
redirect($returnurl);

redirect($returnurl);
Loading

0 comments on commit f83776f

Please sign in to comment.