Skip to content
Browse files

When using loginas to be a student, you can now return to being

yourself using a link in the footer.  Improvements to footer display
  • Loading branch information...
1 parent 7cbfca1 commit 65ccdd8cc8734005232e6ef126f4ae0e60cd0c77 moodler committed Nov 6, 2002
Showing with 27 additions and 14 deletions.
  1. +13 −1 course/loginas.php
  2. +14 −13 lib/moodlelib.php
View
14 course/loginas.php
@@ -5,14 +5,26 @@
require("lib.php");
require_variable($id); // course id
- require_variable($user); // login as this user
+ optional_variable($user); // login as this user
+ optional_variable($return); // return to being the real user again
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
}
require_login($course->id);
+ if ($return and $USER->realuser) {
+ $USER = get_user_info_from_db("id", $USER->realuser);
+ $USER->loggedin = true;
+ $USER->site = $CFG->wwwroot;
+ save_session("USER");
+ redirect($HTTP_REFERER);
+ exit;
+ }
+
+ // $user must be defined to go on
+
if (!isteacher($course->id)) {
error("Only teachers can use this page!");
}
View
27 lib/moodlelib.php
@@ -68,42 +68,43 @@ function print_footer ($course=NULL) {
// to the course home page, otherwise the link will go to the site home
global $USER, $CFG, $THEME;
+
+/// Course links
if ($course) {
if ($course == "home") { // special case for site home page - please do not remove
$homelink = "<P ALIGN=center><A TITLE=\"Moodle $CFG->release ($CFG->version)\" HREF=\"http://moodle.com/\">";
$homelink .= "<BR><IMG WIDTH=130 HEIGHT=19 SRC=\"pix/madewithmoodle2.gif\" BORDER=0></A></P>";
+
+ $course = get_site();
} else {
$homelink = "<A TARGET=_top HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>";
}
} else {
$homelink = "<A TARGET=_top HREF=\"$CFG->wwwroot\">".get_string("home")."</A>";
+ $course = get_site();
}
+
+/// User links
if ($USER->realuser) {
if ($realuser = get_record("user", "id", $USER->realuser)) {
- $realuserinfo = " [$realuser->firstname $realuser->lastname] ";
+ $realuserinfo = " [<A HREF=\"$CFG->wwwroot/course/loginas.php?id=$course->id&return=$realuser->id\">$realuser->firstname $realuser->lastname</A>] ";
}
}
+
if ($USER->id) {
- if ($course) {
- if ($course == "home") {
- $site = get_site();
- $username = "<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$site->id\">$USER->firstname $USER->lastname</A>";
- } else {
- $username = "<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$USER->firstname $USER->lastname</A>";
- }
- } else {
- $username = "$USER->firstname $USER->lastname";
- }
+ $username = "<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$USER->firstname $USER->lastname</A>";
$loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
" (<A HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A>)";
- } else {
+ } else {
$loggedinas = get_string("loggedinnot", "moodle").
" (<A HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A>)";
- }
+ }
include ("$CFG->dirroot/theme/$CFG->theme/footer.html");
}
+
+
function print_navigation ($navigation) {
global $CFG;

0 comments on commit 65ccdd8

Please sign in to comment.
Something went wrong with that request. Please try again.