]> git.mjollnir.org Git - moodle.git/commitdiff
When logging in as a user, take on their "current group" setting too,
authormoodler <moodler>
Sat, 10 Jan 2004 14:25:18 +0000 (14:25 +0000)
committermoodler <moodler>
Sat, 10 Jan 2004 14:25:18 +0000 (14:25 +0000)
then afterwards return teacher to their old setting

course/loginas.php

index b71342315e5de785ff3b2748fed7e73cadab4576..d5eef4e8e6ec7f2a3ac7f8e962a6df306875fae3 100644 (file)
         $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;
     }
     $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);