Commit 33993a71 authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #107051 by webchick, gdevlugt, vladimir.dolgopolov, swentel, Dave Reid,...

Issue #107051 by webchick, gdevlugt, vladimir.dolgopolov, swentel, Dave Reid, tuffnatty, zyware, crifi, tobiasb: Fix for users showing multiple times in the who's online block
parent e6d44cb5
...@@ -773,17 +773,7 @@ function user_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -773,17 +773,7 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
// Perform database queries to gather online user lists. We use s.timestamp // Perform database queries to gather online user lists. We use s.timestamp
// rather than u.access because it is much faster. // rather than u.access because it is much faster.
$anonymous_count = sess_count($interval); $anonymous_count = sess_count($interval);
$authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval); $authenticated_count = db_result(db_query('SELECT COUNT(DISTINCT s.uid) FROM {sessions} s WHERE s.timestamp >= %d AND s.uid > 0', $interval));
$authenticated_count = 0;
$max_users = variable_get('user_block_max_list_count', 10);
$items = array();
while ($account = db_fetch_object($authenticated_users)) {
if ($max_users > 0) {
$items[] = $account;
$max_users--;
}
$authenticated_count++;
}
// Format the output with proper grammar. // Format the output with proper grammar.
if ($anonymous_count == 1 && $authenticated_count == 1) { if ($anonymous_count == 1 && $authenticated_count == 1) {
...@@ -796,6 +786,10 @@ function user_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -796,6 +786,10 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
// Display a list of currently online users. // Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10); $max_users = variable_get('user_block_max_list_count', 10);
if ($authenticated_count && $max_users) { if ($authenticated_count && $max_users) {
$authenticated_users = db_query_range('SELECT u.uid, u.name, MAX(s.timestamp) AS timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY s.timestamp DESC', $interval, 0, $max_users);
while ($account = db_fetch_object($authenticated_users)) {
$items[] = $account;
}
$output .= theme('user_list', $items, t('Online users')); $output .= theme('user_list', $items, t('Online users'));
} }
......
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