mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
New usergetmidnight function and use in finding today's logs
This commit is contained in:
parent
8c0de43cb8
commit
edf7fe8c19
@ -38,9 +38,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
|
||||
$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
|
||||
$timemidnight = usergetmidnight($timenow);
|
||||
|
||||
// Put today up the top of the list
|
||||
$dates = array("$timemidnight" => "Today, ".userdate($timenow, "j F Y") );
|
||||
|
@ -246,6 +246,22 @@ function usertime($date, $timezone=99) {
|
||||
return $date - (int)($timezone * 3600);
|
||||
}
|
||||
|
||||
function usergetmidnight($date, $timezone=99) {
|
||||
// Given a time, return the GMT timestamp of the most recent midnight
|
||||
// for the current user.
|
||||
|
||||
global $USER;
|
||||
|
||||
if ($timezone == 99) {
|
||||
$timezone = (float)$USER->timezone;
|
||||
}
|
||||
|
||||
$userdate = usergetdate($date, $timezone);
|
||||
$timemidnight = gmmktime (0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
|
||||
return usertime($timemidnight, $timezone); // Time of midnight of this user's day, in GMT
|
||||
|
||||
}
|
||||
|
||||
function usertimezone($timezone=99) {
|
||||
// returns a string that prints the user's timezone
|
||||
global $USER;
|
||||
|
@ -75,10 +75,9 @@ function print_user($user, $course, $teacherlinks) {
|
||||
|
||||
echo "<FONT SIZE=1>";
|
||||
if ($teacherlinks) {
|
||||
$tt = usergetdate(time());
|
||||
$today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
|
||||
$timemidnight = usergetmidnight(time());
|
||||
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>";
|
||||
echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id&date=$timemidnight\">Today's logs</A><BR>";
|
||||
echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id\">All logs</A><BR>";
|
||||
if (isstudent($course->id, $user->id)) {
|
||||
echo "<A HREF=\"../course/loginas.php?id=$course->id&user=$user->id\">Login as</A><BR>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user