function _drupalchat_buddylist_online in DrupalChat 6
Same name and namespace in other branches
- 6.2 drupalchat.module \_drupalchat_buddylist_online()
- 7.2 drupalchat.module \_drupalchat_buddylist_online()
- 7 drupalchat.module \_drupalchat_buddylist_online()
2 calls to _drupalchat_buddylist_online()
- drupalchat_poll in ./
drupalchat.module - Process and get messages
- _drupalchat_chat in ./
drupalchat.module
File
- ./
drupalchat.module, line 316 - Module code for DrupalChat.
Code
function _drupalchat_buddylist_online($buddylist) {
global $user;
$users = array();
if (variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH) > DRUPALCHAT_REL_AUTH) {
// Return empty on an empty buddylist
if (empty($buddylist)) {
$users['total'] = 0;
return $users;
}
foreach ($buddylist as $uid) {
$where[] = 'uid = %d';
$args[] = $uid;
}
$result = db_query('SELECT uid, name, status FROM {drupalchat_users} WHERE timestamp >= ' . (time() - 5) . ' AND (' . implode(' OR ', $where) . ') ORDER BY status, name', $args);
}
else {
$result = db_query('SELECT uid, name, status FROM {drupalchat_users} WHERE timestamp >= %d AND uid <> %d ORDER BY status, name', time() - 10, $user->uid);
}
while ($buddy = db_fetch_object($result)) {
$users[$buddy->uid] = array(
'name' => $buddy->name,
'status' => $buddy->status,
);
}
$users['total'] = count($users);
return $users;
}