Menu callback; presents the "Top users" page.
1 string reference to 'statistics_top_users'
- statistics_menu in modules/
statistics.module - Implementation of hook_menu().
File
- modules/
statistics.module, line 278 - Logs access statistics for your site.
Code
function statistics_top_users() {
$header = array(
array(
'data' => t('Hits'),
'field' => 'hits',
'sort' => 'desc',
),
array(
'data' => t('User'),
'field' => 'u.name',
),
);
$sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.uid, u.name" . tablesort_sql($header);
$sql_cnt = "SELECT COUNT(DISTINCT(uid)) FROM {accesslog}";
$result = pager_query($sql, 30, 0, $sql_cnt);
while ($account = db_fetch_object($result)) {
$rows[] = array(
$account->hits,
format_name($account),
);
}
if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
$rows[] = array(
array(
'data' => $pager,
'colspan' => '2',
),
);
}
drupal_set_title(t('Top users in the past %interval', array(
'%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)),
)));
print theme('page', theme('table', $header, $rows));
}