When logging in as a user, take on their "current group" setting too,

then afterwards return teacher to their old setting
This commit is contained in:
moodler 2004-01-10 14:25:18 +00:00
parent 7692b869ef
commit 6e51e14435

View File

@ -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);