Commit 5777b4aa authored by Nigel McNie's avatar Nigel McNie Committed by Richard Mansfield
Browse files

Make the online users sideblock work when there are no online users.

You'd think this would never happen, but it can if a page is defined as PUBLIC and has the sideblock on it.
parent 3a403c4b
......@@ -1943,22 +1943,27 @@ function onlineusers_sideblock() {
$onlineusers = get_records_select_array('usr', 'deleted = 0 AND lastaccess > ?',
array(db_format_timestamp(time() - get_config('accessidletimeout'))), 'lastaccess DESC');
foreach ($onlineusers as &$user) {
// Use 'profileiconbyid' for the current user, just in case they change their profile icon
if ($user->id == $USER->get('id')) {
$user->profileiconurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . (int)$user->profileicon . '&size=20x20';
}
else {
$user->profileiconurl = get_config('wwwroot') . 'thumb.php?type=profileicon&id=' . $user->id . '&size=20x20';
}
if ($onlineusers) {
foreach ($onlineusers as &$user) {
// Use 'profileiconbyid' for the current user, just in case they change their profile icon
if ($user->id == $USER->get('id')) {
$user->profileiconurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . (int)$user->profileicon . '&size=20x20';
}
else {
$user->profileiconurl = get_config('wwwroot') . 'thumb.php?type=profileicon&id=' . $user->id . '&size=20x20';
}
// If the user is an MNET user, show where they've come from
$authobj = AuthFactory::create($user->authinstance);
if ($authobj->authname == 'xmlrpc') {
$peer = get_peer($authobj->wwwroot);
$user->loggedinfrom = $peer->name;
// If the user is an MNET user, show where they've come from
$authobj = AuthFactory::create($user->authinstance);
if ($authobj->authname == 'xmlrpc') {
$peer = get_peer($authobj->wwwroot);
$user->loggedinfrom = $peer->name;
}
}
}
else {
$onlineusers = array();
}
return array(
'users' => $onlineusers,
'count' => count($onlineusers),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment