]> git.mjollnir.org Git - moodle.git/commitdiff
Merging changes from MOODLE_14_STABLE
authordefacer <defacer>
Tue, 31 Aug 2004 10:47:24 +0000 (10:47 +0000)
committerdefacer <defacer>
Tue, 31 Aug 2004 10:47:24 +0000 (10:47 +0000)
blocks/online_users/block_online_users.php
blocks/participants/block_participants.php
mod/chat/lib.php

index 268dfcdcb0ae1c4d8a598c2c557c3f1110c78c6e..2d71dd9cb02b29f4cf123ecdedc6e9f3f91ade26 100644 (file)
@@ -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 = '<b>'.fullname($user).'</b>';
-                    $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 = '<b>'.fullname($teacher).'</b>';
-                    $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 = '<b>'.fullname($teacher).'</b>';
+                $users[$teacher->id] = $teacher;
             }
         }
 
+
         //Calculate minutes
         $minutes  = floor($timetoshowusers/60);
 
index e107e842b6a9fe8a0fcd7073c138882137ff77b8..a67a57103ed1fa29363bcb4c69eecccd7667d023 100644 (file)
@@ -27,8 +27,10 @@ class CourseBlock_participants extends MoodleBlock {
         $strgroups   = get_string('groups');
         $strgroupmy  = get_string('groupmy');
 
-        $this->content->items[]='<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?id='.$this->course->id.'">'.get_string('participants').'</a>';
-        $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
+        if ($this->course->category or $CFG->showsiteparticipantslist > 1 or ($CFG->showsiteparticipantslist == 1 and isteacher()) or isteacher(SITEID)) {
+            $this->content->items[]='<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?id='.$this->course->id.'">'.get_string('participants').'</a>';
+            $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
+        }
 
         if ($this->course->groupmode or !$this->course->groupmodeforce) {
             if ($this->course->groupmode == VISIBLEGROUPS or isteacheredit($this->course->id)) {
index c8761513988fc95ccac54a3a6f67bfac2779d754..81f37fc635f7d89bc6e6a2657bc922a76bb408c1 100644 (file)
@@ -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);