]> git.mjollnir.org Git - moodle.git/commitdiff
Merged in changes for lastaccess on site level from stable
authormoodler <moodler>
Wed, 27 Oct 2004 06:01:20 +0000 (06:01 +0000)
committermoodler <moodler>
Wed, 27 Oct 2004 06:01:20 +0000 (06:01 +0000)
user/view.php

index f94557c359e7d6a104f7e0de3e09d38112125a7f..f7e505be21e596572fd22443c0abe110245b3a33 100644 (file)
 
     add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
 
-    if ($student = get_record("user_students", "userid", $user->id, "course", $course->id)) {
-        $user->lastaccess = $student->timeaccess;
-    } else if ($teacher = get_record("user_teachers", "userid", $user->id, "course", $course->id)) {
-        $user->lastaccess = $teacher->timeaccess;
+    if ($course->id != SITEID) {
+        if ($student = get_record("user_students", "userid", $user->id, "course", $course->id)) {
+            $user->lastaccess = $student->timeaccess;
+        } else if ($teacher = get_record("user_teachers", "userid", $user->id, "course", $course->id)) {
+            $user->lastaccess = $teacher->timeaccess;
+        }
     }
 
     $fullname = fullname($user, isteacher($course->id));
        ($user->maildisplay == 2 and $course->category and !isguest()) or
        isteacher($course->id)) {
 
+        $emailswitch = '';
+
         if (isteacheredit($course->id) or $currentuser) {   /// Can use the enable/disable email stuff
-            if (!empty($_GET['enable'])) {     /// Recieved a paramter to enable the email address
+            if (!empty($_GET['enable'])) {     /// Recieved a parameter to enable the email address
                 set_field('user', 'emailstop', 0, 'id', $user->id);
                 $user->emailstop = 0;
             }
-            if (!empty($_GET['disable'])) {     /// Recieved a paramter to disable the email address
+            if (!empty($_GET['disable'])) {     /// Recieved a parameter to disable the email address
                 set_field('user', 'emailstop', 1, 'id', $user->id);
                 $user->emailstop = 1;
             }
+        }
+
+        if (isteacheredit($course->id)) {   /// Can use the enable/disable email stuff
             if ($user->emailstop) {
                 $switchparam = 'enable';
                 $switchtitle = get_string('emaildisable');
                 $switchclick = get_string('emaildisableclick');
                 $switchpix   = 'email.gif';
             }
-            $emailswitch = "&nbsp;<a title=\"$switchclick\" ".
-                           "href=\"view.php?id=$user->id&amp;course=$course->id&amp;$switchparam=$user->id\">".
-                           "<img border=\"0\" width=\"11\" height=\"11\" src=\"$CFG->pixpath/t/$switchpix\" alt=\"\" /></a>";
-        } else {
-            $emailswitch = '';
+            $emailswitch = "&nbsp<a title=\"$switchclick\" ".
+                           "href=\"view.php?id=$user->id&course=$course->id&$switchparam=1\">".
+                           "<img border=\"0\" width=11 height=11 src=\"$CFG->pixpath/t/$switchpix\"></a>";
+
+        } else if ($currentuser) {         /// Can only re-enable an email this way
+            if ($user->emailstop) {   // Include link that tells how to re-enable their email
+                $switchparam = 'enable';
+                $switchtitle = get_string('emaildisable');
+                $switchclick = get_string('emailenableclick');
+
+                $emailswitch = "&nbsp(<a title=\"$switchclick\" ".
+                               "href=\"view.php?id=$user->id&course=$course->id&enable=1\">$switchtitle</a>)";
+            }
         }
 
         print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");