From: defacer Date: Tue, 31 Aug 2004 10:47:24 +0000 (+0000) Subject: Merging changes from MOODLE_14_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c7756c734cedaac6b72b915a9e0abbaf86acb913;p=moodle.git Merging changes from MOODLE_14_STABLE --- diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index 268dfcdcb0..2d71dd9cb0 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -46,70 +46,70 @@ class CourseBlock_online_users extends MoodleBlock { } $timefrom = time()-$timetoshowusers; - $users = array(); + //Calculate if we are in separate groups + $isseparategroups = ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce and + !isteacheredit($this->course->id)); - if (!$this->course->category and $CFG->allusersaresitestudents) { - if ($users = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess - FROM {$CFG->prefix}user u - WHERE u.lastaccess > $timefrom - ORDER BY u.lastaccess DESC")) { - foreach ($users as $user) { - $user->fullname = ''.fullname($user).''; - $users[$user->id] = $user; - } - } + //Get the user current group + $currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL; - } else { + $groupmembers = ""; + $groupselect = ""; - //Calculate if we are in separate groups - $isseparategroups = ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce and - !isteacheredit($this->course->id)); + //Add this to the SQL to show only group users + if ($currentgroup !== NULL) { + $groupmembers = ", {$CFG->prefix}groups_members gm "; + $groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'"; + } - //Get the user current group - $currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL; + if (empty($this->course->category)) { // Site-level + $courseselect = ''; + $timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)"; + } else { + $courseselect = "AND s.course = '".$this->course->id."'"; + $timeselect = "AND s.timeaccess > $timefrom"; + } - $groupmembers = ""; - $groupselect = ""; + $users = array(); - //Add this to the SQL to show only group users - if ($currentgroup !== NULL) { - $groupmembers = ", {$CFG->prefix}groups_members gm "; - $groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'"; + if ($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")) { + foreach ($students as $student) { + $student->fullname = fullname($student); + $users[$student->id] = $student; } + } - if (empty($this->course->category)) { // Site-level - $courseselect = ''; - $timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)"; - } else { - $courseselect = "AND s.course = '".$this->course->id."'"; - $timeselect = "AND s.timeaccess > $timefrom"; + if (!$this->course->category and $CFG->allusersaresitestudents) { + if ($siteusers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess + FROM {$CFG->prefix}user u + WHERE u.lastaccess > $timefrom AND u.username <> 'guest' + ORDER BY u.lastaccess DESC")) { + foreach ($siteusers as $siteuser) { + $siteuser->fullname = fullname($siteuser); + $siteuser->timeaccess = $siteuser->lastaccess; + $users[$siteuser->id] = $siteuser; + } } + } - if ($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")) { - foreach ($students as $student) { - $student->fullname = fullname($student); - $users[$student->id] = $student; - } - } - - if ($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 - WHERE u.id = s.userid $courseselect $groupselect $timeselect - ORDER BY s.timeaccess DESC")) { - foreach ($teachers as $teacher) { - $teacher->fullname = ''.fullname($teacher).''; - $users[$teacher->id] = $teacher; - } + if ($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 + WHERE u.id = s.userid $courseselect $groupselect $timeselect + ORDER BY s.timeaccess DESC")) { + foreach ($teachers as $teacher) { + $teacher->fullname = ''.fullname($teacher).''; + $users[$teacher->id] = $teacher; } } + //Calculate minutes $minutes = floor($timetoshowusers/60); diff --git a/blocks/participants/block_participants.php b/blocks/participants/block_participants.php index e107e842b6..a67a57103e 100644 --- a/blocks/participants/block_participants.php +++ b/blocks/participants/block_participants.php @@ -27,8 +27,10 @@ class CourseBlock_participants extends MoodleBlock { $strgroups = get_string('groups'); $strgroupmy = get_string('groupmy'); - $this->content->items[]=''.get_string('participants').''; - $this->content->icons[]=''; + if ($this->course->category or $CFG->showsiteparticipantslist > 1 or ($CFG->showsiteparticipantslist == 1 and isteacher()) or isteacher(SITEID)) { + $this->content->items[]=''.get_string('participants').''; + $this->content->icons[]=''; + } if ($this->course->groupmode or !$this->course->groupmodeforce) { if ($this->course->groupmode == VISIBLEGROUPS or isteacheredit($this->course->id)) { diff --git a/mod/chat/lib.php b/mod/chat/lib.php index c876151398..81f37fc635 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -367,7 +367,7 @@ function chat_delete_old_users() { global $CFG; $timeold = time() - $CFG->chat_old_ping; - $query = "lastping < '$timeold' AND version != 'sockets'"; + $query = "lastping < '$timeold'"; if ($oldusers = get_records_select("chat_users", $query) ) { delete_records_select("chat_users", $query);