From: moodler Date: Thu, 21 Oct 2004 15:50:58 +0000 (+0000) Subject: Merged bug 2114 fix from STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=062369857b9e74fe55034f00b1e2aa313271395d;p=moodle.git Merged bug 2114 fix from STABLE --- diff --git a/course/loginas.php b/course/loginas.php index 0563fbdb60..b638ace36f 100644 --- a/course/loginas.php +++ b/course/loginas.php @@ -4,9 +4,10 @@ require_once("../config.php"); require_once("lib.php"); - require_variable($id); // course id + require_variable($id); // course id optional_variable($user); // login as this user - optional_variable($return); // return to being the real user again + optional_variable($return); // return to the page we came from + if (! $course = get_record("course", "id", $id)) { error("Course ID was incorrect"); @@ -16,7 +17,7 @@ require_login($course->id); } - if ($return and $USER->realuser) { + if ($USER->realuser) { /// Reset user back to their real self $USER = get_user_info_from_db("id", $USER->realuser); $USER->loggedin = true; $USER->site = $CFG->wwwroot; @@ -30,8 +31,10 @@ unset($SESSION->oldtimeaccess); } - redirect($_SERVER["HTTP_REFERER"]); - exit; + if ($return) { /// That's all we wanted to do, so let's go back + redirect($_SERVER["HTTP_REFERER"]); + exit; + } } // $user must be defined to go on