Skip to content

Commit

Permalink
improvement of online_users block on front page, suggested by Bruno, …
Browse files Browse the repository at this point in the history
…see bug # 1821
  • Loading branch information
gustav_delius committed Aug 28, 2004
1 parent 944d82d commit 02e0b42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blocks/online_users/block_online_users.php
Expand Up @@ -67,20 +67,20 @@ function get_content() {

if (empty($this->course->category)) { // Site-level
$courseselect = '';
$timeselect = "AND u.lastaccess > $timefrom";
$timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)";
} else {
$courseselect = "AND s.course = '".$this->course->id."'";
$timeselect = "AND s.timeaccess > $timefrom";
}

$students = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess
$students = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess, s.timeaccess
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_students s
$groupmembers
WHERE u.id = s.userid $courseselect $groupselect $timeselect
ORDER BY s.timeaccess DESC");

$teachers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess
$teachers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess, s.timeaccess
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_teachers s
$groupmembers
Expand Down Expand Up @@ -114,7 +114,7 @@ function get_content() {
if ($users !== null) {
foreach ($users as $user) {
$this->content->text .= '<div style="text-align: left; font-size: 0.75em; padding-top: 5px;">';
$timeago = format_time(time() - $user->timeaccess);
$timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage
if ($user->picture==0) {
$this->content->text .= '<img src="'.$CFG->pixpath.'/i/user.gif" style="height: 16px; width=16px; vertical-align: middle;" alt=""> ';
} else {
Expand Down

0 comments on commit 02e0b42

Please sign in to comment.