By dimitris_s on
I have a node where I have this php :
<?php
$number = db_result(db_query('SELECT COUNT(uid) AS number FROM {users} WHERE status=1'));
if (user_access('access content')) {
// Count users with activity in the past defined period.
$time_period = variable_get('user_block_seconds_online', 3600);
// Perform database queries to gather online user lists.
$guests = db_fetch_object(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period));
$users = db_query('SELECT uid, name, access FROM {users} WHERE access >= %d AND uid != 0 ORDER BY access DESC', time() - $time_period);
$total_users = db_num_rows($users);
// Format the output with proper grammar.
echo "";
if ($total_users == 1 && $guests->count == 1) {
$output = t('%members and %visitors online.', array('%members' => format_plural($total_users, 'there is currently 1 user', 'there are currently @count users'), '%visitors' => format_plural($guests->count, '1 guest', '@count guests')));
}
else {
$output = t('<b>Είναι εδώ αυτή τη στιγμή %members και %visitors.</b>', array('%members' => format_plural($total_users, '1 user', '@count users'), '%visitors' => format_plural($guests->count, '1 guest', '@count guests')));
}
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 200);
if ($total_users && $max_users) {
$items = array();
while ($max_users-- && $account = db_fetch_object($users)) {
$items[] = $account;
}
$output .= theme('user_list', $items, t('Online users'));
}
}
return $output;
?>
The problem is that even that I have 200 users to be listed, I only get 10 users like I have in the who's online block. What am I doing wrong? What's the way to list all users online?
Comments
...
The code looks fine. The problem is probably here:
If you already have a Drupal varibale 'user_block_max_list_count' defined, it will override the '200'. Change this line to:
(But it is not "nice" to hard-code values in code.)
Τhank you very much my
Τhank you very much my friend. I think that did the trick. I'll wait for 10+ users to be online so I can test if it works :-)
Thanks again
http://www.dobro.gr - Online community for Greek students in Bulgaria
http://simpledesigns.hopto.org - simple designs