statistics_top_users
- Versions
- 4.6
statistics_top_users()
Menu callback; presents the "Top users" page.
Code
modules/statistics.module, line 278
<?php
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));
}
?>Login or register to post comments 