mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Changes related to timezone display. Datetime display now uses userdate()
which itself uses the USER variable timezone to alter the displayed time.
This commit is contained in:
parent
c5db2fd03f
commit
873960de8c
@ -8,10 +8,6 @@ $FORMATS = array (
|
||||
);
|
||||
|
||||
|
||||
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
|
||||
@ -36,11 +32,11 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
|
||||
// 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") {
|
||||
@ -106,8 +102,8 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -28,7 +28,7 @@
|
||||
$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",
|
||||
|
@ -20,7 +20,7 @@
|
||||
"<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");
|
||||
|
@ -535,7 +535,7 @@ function displaydir ($wdir) {
|
||||
$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>";
|
||||
|
||||
@ -561,7 +561,7 @@ function displaydir ($wdir) {
|
||||
$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>";
|
||||
|
||||
|
@ -23,6 +23,7 @@ CREATE TABLE course (
|
||||
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',
|
||||
|
@ -178,8 +178,22 @@ function print_editing_switch($courseid) {
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,14 +163,18 @@ function close_window_button() {
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -65,7 +65,7 @@
|
||||
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>";
|
||||
|
@ -4,8 +4,4 @@ $RATING = array ("3" => "Outstanding",
|
||||
"2" => "Satisfactory",
|
||||
"1" => "Not satisfactory");
|
||||
|
||||
function journaldate($date) {
|
||||
return date("l, j F Y, g:i A T", $date);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -16,7 +16,7 @@
|
||||
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>";
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
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>";
|
||||
}
|
||||
|
@ -106,7 +106,7 @@
|
||||
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>";
|
||||
|
||||
@ -128,7 +128,7 @@
|
||||
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);
|
||||
|
@ -45,7 +45,7 @@
|
||||
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) {
|
||||
@ -54,7 +54,7 @@
|
||||
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);
|
||||
|
@ -82,15 +82,15 @@
|
||||
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) {
|
||||
@ -101,7 +101,7 @@
|
||||
|
||||
} else {
|
||||
echo "<P><B>This journal won't be open until: ";
|
||||
echo journaldate($timestart)."</B></P>";
|
||||
echo userdate($timestart)."</B></P>";
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
@ -122,7 +122,7 @@ function print_feedback($course, $entry) {
|
||||
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\">";
|
||||
|
@ -142,7 +142,7 @@
|
||||
$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) {
|
||||
@ -194,7 +194,7 @@
|
||||
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"];
|
||||
|
@ -190,7 +190,7 @@
|
||||
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];
|
||||
@ -330,7 +330,7 @@ function print_all_responses($survey, $results) {
|
||||
|
||||
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>";
|
||||
}
|
||||
|
@ -51,6 +51,31 @@
|
||||
<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>
|
||||
|
@ -99,8 +99,16 @@
|
||||
|
||||
$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)");
|
||||
|
@ -76,7 +76,7 @@ function print_user($user, $course, $teacherlinks) {
|
||||
|
||||
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>";
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
/// 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user