Merging changes from MOODLE_14_STABLE

This commit is contained in:
defacer 2004-08-31 10:47:24 +00:00
parent 1b867d15b0
commit c7756c734c
3 changed files with 60 additions and 58 deletions

View File

@ -46,70 +46,70 @@ class CourseBlock_online_users extends MoodleBlock {
}
$timefrom = time()-$timetoshowusers;
//Calculate if we are in separate groups
$isseparategroups = ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce and
!isteacheredit($this->course->id));
//Get the user current group
$currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL;
$groupmembers = "";
$groupselect = "";
//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 (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";
}
$users = array();
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 (!$this->course->category and $CFG->allusersaresitestudents) {
if ($users = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess
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
WHERE u.lastaccess > $timefrom AND u.username <> 'guest'
ORDER BY u.lastaccess DESC")) {
foreach ($users as $user) {
$user->fullname = '<b>'.fullname($user).'</b>';
$users[$user->id] = $user;
}
}
} else {
//Calculate if we are in separate groups
$isseparategroups = ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce and
!isteacheredit($this->course->id));
//Get the user current group
$currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL;
$groupmembers = "";
$groupselect = "";
//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 (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 ($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;
foreach ($siteusers as $siteuser) {
$siteuser->fullname = fullname($siteuser);
$siteuser->timeaccess = $siteuser->lastaccess;
$users[$siteuser->id] = $siteuser;
}
}
}
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);

View 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)) {

View 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);