From: gustav_delius Date: Thu, 26 Aug 2004 04:16:52 +0000 (+0000) Subject: fixed bug in online user list, see http://moodle.org/mod/forum/discuss.php?d=11554 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4202155868bb9e6db51b134b30496d7f5081589a;p=moodle.git fixed bug in online user list, see http://moodle.org/mod/forum/discuss.php?d=11554 --- diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index da7cf35cdd..eb21824ae7 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -63,28 +63,28 @@ class CourseBlock_online_users extends MoodleBlock { $groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'"; } + $timefrom = time()-$timetoshowusers; + if (empty($this->course->category)) { // Site-level $courseselect = ''; + $timeselect = "AND u.lastaccess > $timefrom"; } else { $courseselect = "AND s.course = '".$this->course->id."'"; + $timeselect = "AND s.timeaccess > $timefrom"; } - $timefrom = time()-$timetoshowusers; - $students = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess FROM {$CFG->prefix}user u, {$CFG->prefix}user_students s $groupmembers - WHERE u.id = s.userid $courseselect $groupselect - AND s.timeaccess > $timefrom + 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 FROM {$CFG->prefix}user u, {$CFG->prefix}user_teachers s $groupmembers - WHERE u.id = s.userid $courseselect $groupselect - AND s.timeaccess > $timefrom + WHERE u.id = s.userid $courseselect $groupselect $timeselect ORDER BY s.timeaccess DESC"); if ($teachers || $students) {