From: moodler Date: Sat, 10 Jan 2004 14:25:18 +0000 (+0000) Subject: When logging in as a user, take on their "current group" setting too, X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6e51e14435efb8058b45eaffa688384d2114d6ff;p=moodle.git When logging in as a user, take on their "current group" setting too, then afterwards return teacher to their old setting --- diff --git a/course/loginas.php b/course/loginas.php index b71342315e..d5eef4e8e6 100644 --- a/course/loginas.php +++ b/course/loginas.php @@ -18,6 +18,12 @@ $USER = get_user_info_from_db("id", $USER->realuser); $USER->loggedin = true; $USER->site = $CFG->wwwroot; + + if (isset($SESSION->oldcurrentgroup)) { // Restore previous "current group" + $SESSION->currentgroup[$course->id] = $SESSION->oldcurrentgroup; + unset($SESSION->oldcurrentgroup); + } + redirect($_SERVER["HTTP_REFERER"]); exit; } @@ -41,11 +47,16 @@ $teacher_name = fullname($USER, true); $teacher_id = "$USER->id"; - $USER = get_user_info_from_db("id", $user); + $USER = get_user_info_from_db("id", $user); // Create the new USER object with all details $USER->loggedin = true; $USER->site = $CFG->wwwroot; $USER->realuser = $teacher_id; + if (isset($SESSION->currentgroup[$course->id])) { // Remember current setting for later + $SESSION->oldcurrentgroup = $SESSION->currentgroup[$course->id]; + unset($SESSION->currentgroup[$course->id]); + } + set_moodle_cookie($USER->username); $student_name = fullname($USER, true);