]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes related to user timezones. All times are now displayed as expected.
authormartin <martin>
Mon, 10 Jun 2002 09:44:37 +0000 (09:44 +0000)
committermartin <martin>
Mon, 10 Jun 2002 09:44:37 +0000 (09:44 +0000)
course/lib.php
course/log.php

index 7b59d9f6993a0cc9cd0f21a78d9a9c777d908c81..80b33507363c49e1b031c3d3324d9577dedb20b7 100644 (file)
@@ -10,6 +10,8 @@ $FORMATS = array (
 
 function print_log_selector_form($course, $selecteduser=0, $selecteddate="today") {
 
+    global $USER, $CFG;
+
     // Get all the possible users
     $users = array();
     if ($students = get_records_sql("SELECT u.* FROM user u, user_students s 
@@ -30,13 +32,29 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
     asort($users);
 
     // Get all the possible dates
-    $tt = usergetdate(time());
-    $timemidnight = $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
-    $dates = array("$today" => "Today, ".userdate($today, "j F Y") );
+    // Note that we are keeping track of real (GMT) time and user time
+    // User time is only used in displays - all calcs and passing is GMT
+
+    $timenow = time(); // GMT
+
+    // What day is it now for the user, and when is midnight that day (in GMT).
+    $date = usergetdate($timenow);
+    $timemidnight = gmmktime (0, 0, 0, $date["mon"], $date["mday"], $date["year"]);
+    $timemidnight = usertime($timemidnight); // Time of midnight of this user's day, in GMT
+
+    // Put today up the top of the list
+    $dates = array("$timemidnight" => "Today, ".userdate($timenow, "j F Y") );
+
+    if (! $course->startdate) {
+        $course->startdate = $course->timecreated;
+    }
 
-    while ($timemidnight > $course->startdate) {
+    $numdates = 1;
+    while ($timemidnight > $course->startdate and $numdates < 365) {
         $timemidnight = $timemidnight - 86400;
-        $dates["$timemidnight"] = userdate($timemidnight, "l, j F Y");
+        $timenow = $timenow - 86400;
+        $dates["$timemidnight"] = userdate($timenow, "l, j F Y");
+        $numdates++;
     }
 
     if ($selecteddate == "today") {
@@ -71,6 +89,8 @@ function make_log_url($module, $url) {
 
 
 function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
+// It is assumed that $date is the GMT time of midnight for that day, 
+// and so the next 86400 seconds worth of logs are printed.
 
     $selector = "WHERE l.course='$course->id' AND l.user = u.id";
 
@@ -142,7 +162,8 @@ function print_course($course) {
     echo "<TABLE WIDTH=100%>";
     echo "<TR VALIGN=top>";
     echo "<TD VALIGN=top WIDTH=50%>";
-    echo "<P><FONT SIZE=3><B><A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
+    echo "<P><FONT SIZE=3><B><A TITLE=\"Click to enter this course\" 
+              HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
     if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t 
                                      WHERE u.id = t.user AND t.course = '$course->id' 
                                      ORDER BY t.authority ASC")) {
index 793daec786f830e2251925166e7cc8b97b393842..eba1c37820fa60e26672a89695f705d57bb97ceb 100644 (file)
@@ -11,7 +11,7 @@
         error("That's an invalid course id");
     }
 
-    if ( ! isteacher($course->id)) {
+    if (! isteacher($course->id)) {
         error("Only teachers can view logs");
     }
 
@@ -35,7 +35,7 @@
                      "<A HREF=\"view.php?id=$course->id\">$course->shortname</A> ->
                       <A HREF=\"log.php?id=$course->id\">Logs</A> -> Logs for $userinfo, $dateinfo", "");
         
-        print_heading("Logs for $userinfo, $dateinfo");
+        print_heading("Logs for $userinfo, $dateinfo (".usertimezone().")");
 
         print_log_selector_form($course, $user, $date);