which itself uses the USER variable timezone to alter the displayed time.
);
-function logdate($date) {
- return date("l, j F Y, g:i A", $date);
-}
-
function print_log_selector_form($course, $selecteduser=0, $selecteddate="today") {
// Get all the possible users
// Get all the possible dates
$tt = getdate(time());
$timemidnight = $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
- $dates = array("$today" => "Today, ".date("j F Y", $today) );
+ $dates = array("$today" => "Today, ".userdate($today, "j F Y") );
while ($timemidnight > $course->startdate) {
$timemidnight = $timemidnight - 86400;
- $dates["$timemidnight"] = date("l, j F Y", $timemidnight);
+ $dates["$timemidnight"] = userdate($timemidnight, "l, j F Y");
}
if ($selecteddate == "today") {
}
echo "<TR>";
- echo "<TD ALIGN=right><FONT SIZE=2>".date("l", $log->time)."</TD>";
- echo "<TD><FONT SIZE=2>".date("j M Y, h:i A", $log->time)."</TD>";
+ echo "<TD ALIGN=right><FONT SIZE=2>".userdate($log->time, "l")."</TD>";
+ echo "<TD><FONT SIZE=2>".userdate($log->time, "j M Y, h:i A")."</TD>";
echo "<TD><FONT SIZE=2><B>$log->firstname $log->lastname</B></TD>";
echo "<TD><FONT SIZE=2>";
link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600);
$userinfo = "$u->firstname $u->lastname";
}
if ($date) {
- $dateinfo = date("l, j F Y", $date);
+ $dateinfo = userdate($date, "l, j F Y");
}
print_header("$course->shortname: Logs", "$course->shortname : Logs",
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> What's new");
print_heading("Recent activity since your last login");
- print_heading(logdate($USER->lastlogin));
+ print_heading(userdate($USER->lastlogin));
print_simple_box_start("center");
$modules = array ("users");
$filename = $fullpath."/".$dir;
$fileurl = rawurlencode($wdir."/".$dir);
$filesafe = rawurlencode($dir);
- $filedate = date("d-m-Y H:i:s", filectime($filename));
+ $filedate = userdate(filectime($filename), "d-m-Y H:i:s");
echo "<TR>";
$fileurl = "$wdir/$file";
$filesafe = rawurlencode($file);
$fileurlsafe = rawurlencode($fileurl);
- $filedate = date("d-m-Y H:i:s", filectime($filename));
+ $filedate = userdate(filectime($filename), "d-m-Y H:i:s");
echo "<TR>";
summary text NOT NULL,
format tinyint(4) NOT NULL default '1',
teacher varchar(100) NOT NULL default 'Teacher',
+ student varchar(100) NOT NULL default 'Student',
startdate int(10) unsigned NOT NULL default '0',
enddate int(10) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
}
-function moodledate($date) {
- return date("l, j F Y, g:i A T", $date);
+function userdate($date, $format="l, j F Y, g:i A") {
+ global $USER;
+
+ if (abs($USER->timezone) > 12) {
+ return date("$format T", $date);
+ }
+ return gmdate($format, $date + (int)($USER->timezone * 3600));
+}
+
+function usergetdate($date) {
+ global $USER;
+
+ if (abs($USER->timezone) > 12) {
+ return getdate($date);
+ }
+ return getdate($date + (int)($USER->timezone * 3600));
}
}
-function choose_from_menu ($options, $name, $selected="", $nothing="Choose...", $script="") {
+function choose_from_menu ($options, $name, $selected="", $nothing="Choose...", $script="", $nothingvalue="0") {
// $options["value"]["label"]
if ($script) {
$javascript = "onChange=\"$script\"";
}
echo "<SELECT NAME=$name $javascript>\n";
- echo " <OPTION VALUE=0>$nothing</OPTION>\n";
+ echo " <OPTION VALUE=\"$nothingvalue\"\n";
+ if ($nothingvalue == $selected) {
+ echo " SELECTED";
+ }
+ echo ">$nothing</OPTION>\n";
foreach ($options as $value => $label) {
echo " <OPTION VALUE=\"$value\"";
if ($value == $selected) {
echo "<TD NOWRAP BGCOLOR=\"$THEME->cellheading\">$user->firstname $user->lastname</TD>";
echo "<TD><P> ";
if ($answer->timemodified) {
- echo moodledate($answer->timemodified);
+ echo userdate($answer->timemodified);
}
echo "</P> </TD>";
"2" => "Satisfactory",
"1" => "Not satisfactory");
-function journaldate($date) {
- return date("l, j F Y, g:i A T", $date);
-}
-
?>
echo "<P><B>Journal feedback: $journal->name</B></P>";
echo "<FONT SIZE=2><UL>";
echo "<LI><A HREF=\"/mod/journal/view.php?id=$journal->coursemodule\">Your journal entry</A> has some feedback!";
- echo ", ".moodledate($entry->timemarked);
+ echo ", ".userdate($entry->timemarked);
echo "</UL></FONT>";
}
echo "<FONT SIZE=2><UL>";
foreach ($entries as $entry) {
echo "<LI>$entry->firstname $entry->lastname edited their journal";
- echo ", ".moodledate($entry->modified);
+ echo ", ".userdate($entry->modified);
}
echo "</UL></FONT>";
}
echo "</TD>";
echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$THEME->cellheading\">$student->firstname $student->lastname";
if ($entry) {
- echo " <FONT SIZE=1>Last edited: ".journaldate($entry->modified)."</FONT>";
+ echo " <FONT SIZE=1>Last edited: ".userdate($entry->modified)."</FONT>";
}
echo "</TR>";
echo "<TD BGCOLOR=\"$THEME->cellheading\">Teacher Feedback:";
choose_from_menu($RATING, "r$entry->id", $entry->rating, "Rate...");
if ($entry->timemarked) {
- echo " <FONT SIZE=1>".journaldate($entry->timemarked)."</FONT>";
+ echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
}
echo "<BR><TEXTAREA NAME=\"c$entry->id\" ROWS=4 COLS=60 WRAP=virtual>";
p($entry->comment);
echo "<TD BGCOLOR=\"$THEME->cellcontent\">";
echo "<P><A HREF=\"$CFG->wwwroot/mod/journal/view.php?id=$journal->coursemodule\">$journal->name</A></P>";
if ($entry->modified) {
- echo "<P><FONT SIZE=1>Last edited: ".moodledate($entry->modified)."</FONT></P>";
+ echo "<P><FONT SIZE=1>Last edited: ".userdate($entry->modified)."</FONT></P>";
}
echo text_to_html($entry->text);
if ($entry->teacher) {
print_user_picture($entry->teacher, $course->id, $teachers[$entry->teacher]->picture);
echo "<TD BGCOLOR=\"$THEME->cellheading\">".$RATING[$entry->rating];
if ($entry->timemarked) {
- echo " <FONT SIZE=1>".moodledate($entry->timemarked)."</FONT>";
+ echo " <FONT SIZE=1>".userdate($entry->timemarked)."</FONT>";
}
echo "<BR><FONT COLOR=#000055>";
echo text_to_html($entry->comment);
if ($timenow < $timefinish) {
if ($entry->modified) {
echo "<P><FONT SIZE=-2><B>Last edited:</B> ";
- echo journaldate($entry->modified)."</FONT></P>";
+ echo userdate($entry->modified)."</FONT></P>";
}
if ($journal->days) {
echo "<P><FONT SIZE=-2><B>Editing period ends:</B> ";
- echo journaldate($timefinish)."</FONT></P>";
+ echo userdate($timefinish)."</FONT></P>";
}
} else {
echo "<P><FONT SIZE=-2><B>Editing period has ended:</B> ";
- echo journaldate($timefinish)."</P>";
+ echo userdate($timefinish)."</P>";
}
if ($entry->comment || $entry->rating) {
} else {
echo "<P><B>This journal won't be open until: ";
- echo journaldate($timestart)."</B></P>";
+ echo userdate($timestart)."</B></P>";
}
print_footer($course);
print_user_picture($teacher->id, $course->id, $teacher->picture);
echo "</TD>";
echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$THEME->cellheading\">$teacher->firstname $teacher->lastname";
- echo " <FONT SIZE=2><I>".journaldate($entry->timemarked)."</I>";
+ echo " <FONT SIZE=2><I>".userdate($entry->timemarked)."</I>";
echo "</TR>";
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
$myxls->InsertText($u->lastname);
$myxls->InsertText($u->email);
$myxls->InsertText($u->idnumber);
- $myxls->InsertText( date("d-M-Y h:i:s A", $results["$user"]["time"]) );
+ $myxls->InsertText( userdate($results["$user"]["time"], "d-M-Y h:i:s A") );
$myxls->InsertText($notes);
foreach ($order as $key => $qid) {
echo $u->lastname." ";
echo $u->email." ";
echo $u->idnumber." ";
- echo date("d-M-Y h:i:s A", $results["$user"]["time"])." ";
+ echo userdate($results["$user"]["time"], "d-M-Y h:i:s A")." ";
foreach ($order as $key => $qid) {
$question = $questions["$qid"];
print_user_picture($a->user, $course->id, $a->picture, false);
echo "</TD>";
echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->user\">$a->firstname $a->lastname</A></TD>";
- echo "<TD><P>".date("j M Y h:i A",$a->time)."</TD>";
+ echo "<TD><P>".userdate($a->time, "j M Y h:i A")."</TD>";
echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
if ($a->answer1) {
echo "$a->answer1 - ".$answers[$a->answer1 - 1];
echo "<TR>";
echo "<TD><A HREF=\"report.php?action=student&student=$a->id&id=$survey\">$a->firstname $a->lastname</A></TD>";
- echo "<TD>".date("j M Y, h:i A",$a->time)."</TD>";
+ echo "<TD>".userdate($a->time, "j M Y, h:i A")."</TD>";
echo "<TD align=right>$a->numanswers</TD>";
echo "</TR>";
}
<td><TEXTAREA NAME=description COLS=50 ROWS=10 WRAP=virtual><?=$user->description ?></TEXTAREA>
</td>
</tr>
+<tr valign=top>
+ <td><P>Timezone:</td>
+ <td><?
+ if (abs($user->timezone) > 12) {
+ $user->timezone = 99;
+ }
+ $timenow = time();
+
+ for ($tz = -23; $tz <= 24; $tz++) {
+ $zone = (float)$tz/2.0;
+ $usertime = $timenow + ($tz * 1800);
+ if ($tz == 0) {
+ $timezones["$zone"] = gmdate("D, h:i a", $usertime)." (GMT)";
+ } else if ($tz < 0) {
+ $timezones["$zone"] = gmdate("D, h:i a", $usertime)." (GMT$zone)";
+ } else {
+ $timezones["$zone"] = gmdate("D, h:i a", $usertime)." (GMT+$zone)";
+ }
+ }
+
+ choose_from_menu ($timezones, "timezone", $user->timezone, "Use the server's local time", "", "99");
+
+ ?>
+ (Your current local time)</td>
+</tr>
<tr>
<td></td>
<td><input type="submit" value="Update my profile"></td>
$usernew->timemodified = time();
+
+
if (update_record("user", $usernew)) {
add_to_log($course->id, "user", "update", "view.php?user=$user->id&course=$course->id", "");
+
+ // Copy data into $USER session variable
+ $usernew = (array)$usernew;
+ foreach ($usernew as $variable => $value) {
+ $USER->$variable = $value;
+ }
redirect("view.php?id=$user->id&course=$course->id", "Changes saved");
} else {
error("Could not update the user record ($user->id)");
echo "<FONT SIZE=1>";
if ($teacherlinks) {
- $tt = getdate(time());
+ $tt = usergetdate(time());
$today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
echo "<A HREF=\"../course/user.php?id=$course->id&user=$user->id\">Contributions</A><BR>";
echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id&date=$today\">Today's logs</A><BR>";
/// FUNCTIONS ///////////////////////////////////////////////////////////
-function userdate($date) {
- return date("l, j F Y, g:i A T", $date);
-}
-
function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {
if (function_exists("ImageCopyResampled")) { // Assumes gd >= 2.0.1 as well