diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-08-23 16:34:44 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-08-23 16:34:44 +0000 |
commit | 7b7ab29a22099da05c6e287847561194f9762981 (patch) | |
tree | df0d9295e7ea39f3bbe2e93952c4220ffbcded06 /modules | |
parent | a0f774a15e9c2122b61aa934986f67ed59496ded (diff) | |
download | brdo-7b7ab29a22099da05c6e287847561194f9762981.tar.gz brdo-7b7ab29a22099da05c6e287847561194f9762981.tar.bz2 |
- Patch #169420 by Crell: split statistics module.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/statistics/statistics.admin.inc | 214 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 272 | ||||
-rw-r--r-- | modules/statistics/statistics.pages.inc | 71 |
3 files changed, 293 insertions, 264 deletions
diff --git a/modules/statistics/statistics.admin.inc b/modules/statistics/statistics.admin.inc new file mode 100644 index 000000000..6d68bff59 --- /dev/null +++ b/modules/statistics/statistics.admin.inc @@ -0,0 +1,214 @@ +<?php +// $Id$ + +/** + * @file + * Admin page callbacks for the statistics module. + */ + +/** + * Menu callback; presents the "recent hits" page. + */ +function statistics_recent_hits() { + $header = array( + array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'), + array('data' => t('Page'), 'field' => 'a.path'), + array('data' => t('User'), 'field' => 'u.name'), + array('data' => t('Operations')) + ); + + $sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid'. tablesort_sql($header); + + $result = pager_query($sql, 30); + $rows = array(); + while ($log = db_fetch_object($result)) { + $rows[] = array( + array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), + _statistics_format_item($log->title, $log->path), + theme('username', $log), + l(t('details'), "admin/logs/access/$log->aid")); + } + + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; +} + +/** + * Menu callback; presents the "top pages" page. + */ +function statistics_top_pages() { + $sql = "SELECT COUNT(path) AS hits, path, title, AVG(timer) AS average_time, SUM(timer) AS total_time FROM {accesslog} GROUP BY path, title"; + $sql_cnt = "SELECT COUNT(DISTINCT(path)) FROM {accesslog}"; + + $header = array( + array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), + array('data' => t('Page'), 'field' => 'path'), + array('data' => t('Average page generation time'), 'field' => 'average_time'), + array('data' => t('Total page generation time'), 'field' => 'total_time') + ); + $sql .= tablesort_sql($header); + $result = pager_query($sql, 30, 0, $sql_cnt); + + $rows = array(); + while ($page = db_fetch_object($result)) { + $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000))); + } + + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + + drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; +} + +/** + * Menu callback; presents the "top visitors" page. + */ +function statistics_top_visitors() { + + $header = array( + array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), + array('data' => t('Visitor'), 'field' => 'u.name'), + array('data' => t('Total page generation time'), 'field' => 'total'), + array('data' => t('Operations')) + ); + + $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM {accesslog} a LEFT JOIN {access} ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, ac.aid". tablesort_sql($header); + $sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog}"; + $result = pager_query($sql, 30, 0, $sql_cnt); + + $rows = array(); + while ($account = db_fetch_object($result)) { + $qs = drupal_get_destination(); + $ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array('query' => $qs)) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array('query' => $qs)); + $rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link); + } + + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + + drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; +} + +/** + * Menu callback; presents the "referrer" page. + */ +function statistics_top_referrers() { + $query = "SELECT url, COUNT(url) AS hits, MAX(timestamp) AS last FROM {accesslog} WHERE url NOT LIKE '%%%s%%' AND url <> '' GROUP BY url"; + $query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url NOT LIKE '%%%s%%'"; + drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); + + $header = array( + array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), + array('data' => t('Url'), 'field' => 'url'), + array('data' => t('Last visit'), 'field' => 'last'), + ); + + $query .= tablesort_sql($header); + $result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']); + + $rows = array(); + while ($referrer = db_fetch_object($result)) { + $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(time() - $referrer->last)))); + } + + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3)); + } + + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; +} + +/** + * Menu callback; Displays recent page accesses. + */ +function statistics_access_log($aid) { + $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); + if ($access = db_fetch_object($result)) { + $rows[] = array( + array('data' => t('URL'), 'header' => TRUE), + l(url($access->path, array('absolute' => TRUE)), $access->path) + ); + // It is safe to avoid filtering $access->title through check_plain because + // it comes from drupal_get_title(). + $rows[] = array( + array('data' => t('Title'), 'header' => TRUE), + $access->title + ); + $rows[] = array( + array('data' => t('Referrer'), 'header' => TRUE), + ($access->url ? l($access->url, $access->url) : '') + ); + $rows[] = array( + array('data' => t('Date'), 'header' => TRUE), + format_date($access->timestamp, 'large') + ); + $rows[] = array( + array('data' => t('User'), 'header' => TRUE), + theme('username', $access) + ); + $rows[] = array( + array('data' => t('Hostname'), 'header' => TRUE), + check_plain($access->hostname) + ); + + return theme('table', array(), $rows); + } + else { + drupal_not_found(); + } +} + +/** + * Form builder; Configure access logging. + * + * @ingroup forms + * @see system_settings_form(). + */ +function statistics_access_logging_settings() { + // Access log settings: + $options = array('1' => t('Enabled'), '0' => t('Disabled')); + $form['access'] = array( + '#type' => 'fieldset', + '#title' => t('Access log settings')); + $form['access']['statistics_enable_access_log'] = array( + '#type' => 'radios', + '#title' => t('Enable access log'), + '#default_value' => variable_get('statistics_enable_access_log', 0), + '#options' => $options, + '#description' => t('Log each page access. Required for referrer statistics.')); + $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); + $form['access']['statistics_flush_accesslog_timer'] = array( + '#type' => 'select', + '#title' => t('Discard access logs older than'), + '#default_value' => variable_get('statistics_flush_accesslog_timer', 259200), + '#options' => $period, + '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. Requires crontab.')); + + // count content views settings + $form['content'] = array( + '#type' => 'fieldset', + '#title' => t('Content viewing counter settings')); + $form['content']['statistics_count_content_views'] = array( + '#type' => 'radios', + '#title' => t('Count content views'), + '#default_value' => variable_get('statistics_count_content_views', 0), + '#options' => $options, + '#description' => t('Increment a counter each time content is viewed.')); + + return system_settings_form($form); +} diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 8f33fdacf..8aaaa43ff 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -105,6 +105,7 @@ function statistics_menu() { 'description' => 'View pages that have recently been visited.', 'page callback' => 'statistics_recent_hits', 'access arguments' => array('access statistics'), + 'file' => 'statistics.admin.inc', ); $items['admin/logs/pages'] = array( 'title' => 'Top pages', @@ -112,6 +113,7 @@ function statistics_menu() { 'page callback' => 'statistics_top_pages', 'access arguments' => array('access statistics'), 'weight' => 1, + 'file' => 'statistics.admin.inc', ); $items['admin/logs/visitors'] = array( 'title' => 'Top visitors', @@ -119,12 +121,14 @@ function statistics_menu() { 'page callback' => 'statistics_top_visitors', 'access arguments' => array('access statistics'), 'weight' => 2, + 'file' => 'statistics.admin.inc', ); $items['admin/logs/referrers'] = array( 'title' => 'Top referrers', 'description' => 'View top referrers.', 'page callback' => 'statistics_top_referrers', 'access arguments' => array('access statistics'), + 'file' => 'statistics.admin.inc', ); $items['admin/logs/access/%'] = array( 'title' => 'Details', @@ -133,6 +137,7 @@ function statistics_menu() { 'page arguments' => array(3), 'access arguments' => array('access statistics'), 'type' => MENU_CALLBACK, + 'file' => 'statistics.admin.inc', ); $items['admin/logs/settings'] = array( 'title' => 'Access log settings', @@ -142,6 +147,7 @@ function statistics_menu() { 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, 'weight' => 3, + 'file' => 'statistics.admin.inc', ); $items['user/%user/track/navigation'] = array( 'title' => 'Track page visits', @@ -150,6 +156,7 @@ function statistics_menu() { 'access arguments' => array('access statistics'), 'type' => MENU_LOCAL_TASK, 'weight' => 2, + 'file' => 'statistics.pages.inc', ); $items['node/%node/track'] = array( 'title' => 'Track', @@ -158,6 +165,7 @@ function statistics_menu() { 'access arguments' => array('access statistics'), 'type' => MENU_LOCAL_TASK, 'weight' => 2, + 'file' => 'statistics.pages.inc', ); return $items; @@ -172,268 +180,6 @@ function statistics_user($op, &$edit, &$user) { } } -function statistics_access_log($aid) { - $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); - if ($access = db_fetch_object($result)) { - $rows[] = array( - array('data' => t('URL'), 'header' => TRUE), - l(url($access->path, array('absolute' => TRUE)), $access->path) - ); - // It is safe to avoid filtering $access->title through check_plain because - // it comes from drupal_get_title(). - $rows[] = array( - array('data' => t('Title'), 'header' => TRUE), - $access->title - ); - $rows[] = array( - array('data' => t('Referrer'), 'header' => TRUE), - ($access->url ? l($access->url, $access->url) : '') - ); - $rows[] = array( - array('data' => t('Date'), 'header' => TRUE), - format_date($access->timestamp, 'large') - ); - $rows[] = array( - array('data' => t('User'), 'header' => TRUE), - theme('username', $access) - ); - $rows[] = array( - array('data' => t('Hostname'), 'header' => TRUE), - check_plain($access->hostname) - ); - - return theme('table', array(), $rows); - } - else { - drupal_not_found(); - } -} - -function statistics_node_tracker() { - if ($node = node_load(arg(1))) { - - $header = array( - array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'), - array('data' => t('Referrer'), 'field' => 'a.url'), - array('data' => t('User'), 'field' => 'u.name'), - array('data' => t('Operations'))); - - $result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\''. tablesort_sql($header), 30, 0, NULL, $node->nid); - $rows = array(); - while ($log = db_fetch_object($result)) { - $rows[] = array( - array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), - _statistics_link($log->url), - theme('username', $log), - l(t('details'), "admin/logs/access/$log->aid")); - } - - if (empty($rows)) { - $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); - } - - drupal_set_title(check_plain($node->title)); - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; - } - else { - drupal_not_found(); - } -} - -function statistics_user_tracker() { - if ($account = user_load(array('uid' => arg(1)))) { - - $header = array( - array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'), - array('data' => t('Page'), 'field' => 'path'), - array('data' => t('Operations'))); - - $result = pager_query('SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d'. tablesort_sql($header), 30, 0, NULL, $account->uid); - $rows = array(); - while ($log = db_fetch_object($result)) { - $rows[] = array( - array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), - _statistics_format_item($log->title, $log->path), - l(t('details'), "admin/logs/access/$log->aid")); - } - - if (empty($rows)) { - $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3)); - } - - drupal_set_title(check_plain($account->name)); - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; - } - else { - drupal_not_found(); - } -} - -/** - * Menu callback; presents the "recent hits" page. - */ -function statistics_recent_hits() { - $header = array( - array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'), - array('data' => t('Page'), 'field' => 'a.path'), - array('data' => t('User'), 'field' => 'u.name'), - array('data' => t('Operations')) - ); - - $sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid'. tablesort_sql($header); - - $result = pager_query($sql, 30); - $rows = array(); - while ($log = db_fetch_object($result)) { - $rows[] = array( - array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), - _statistics_format_item($log->title, $log->path), - theme('username', $log), - l(t('details'), "admin/logs/access/$log->aid")); - } - - if (empty($rows)) { - $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); - } - - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; -} - -/** - * Menu callback; presents the "top pages" page. - */ -function statistics_top_pages() { - $sql = "SELECT COUNT(path) AS hits, path, title, AVG(timer) AS average_time, SUM(timer) AS total_time FROM {accesslog} GROUP BY path, title"; - $sql_cnt = "SELECT COUNT(DISTINCT(path)) FROM {accesslog}"; - - $header = array( - array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), - array('data' => t('Page'), 'field' => 'path'), - array('data' => t('Average page generation time'), 'field' => 'average_time'), - array('data' => t('Total page generation time'), 'field' => 'total_time') - ); - $sql .= tablesort_sql($header); - $result = pager_query($sql, 30, 0, $sql_cnt); - - $rows = array(); - while ($page = db_fetch_object($result)) { - $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000))); - } - - if (empty($rows)) { - $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); - } - - drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; -} - -/** - * Menu callback; presents the "top visitors" page. - */ -function statistics_top_visitors() { - - $header = array( - array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), - array('data' => t('Visitor'), 'field' => 'u.name'), - array('data' => t('Total page generation time'), 'field' => 'total'), - array('data' => t('Operations')) - ); - - $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM {accesslog} a LEFT JOIN {access} ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, ac.aid". tablesort_sql($header); - $sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog}"; - $result = pager_query($sql, 30, 0, $sql_cnt); - - $rows = array(); - while ($account = db_fetch_object($result)) { - $qs = drupal_get_destination(); - $ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array('query' => $qs)) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array('query' => $qs)); - $rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link); - } - - if (empty($rows)) { - $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); - } - - drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; -} - -/** - * Menu callback; presents the "referrer" page. - */ -function statistics_top_referrers() { - $query = "SELECT url, COUNT(url) AS hits, MAX(timestamp) AS last FROM {accesslog} WHERE url NOT LIKE '%%%s%%' AND url <> '' GROUP BY url"; - $query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url NOT LIKE '%%%s%%'"; - drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); - - $header = array( - array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), - array('data' => t('Url'), 'field' => 'url'), - array('data' => t('Last visit'), 'field' => 'last'), - ); - - $query .= tablesort_sql($header); - $result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']); - - $rows = array(); - while ($referrer = db_fetch_object($result)) { - $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(time() - $referrer->last)))); - } - - if (empty($rows)) { - $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3)); - } - - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; -} - -function statistics_access_logging_settings() { - // Access log settings: - $options = array('1' => t('Enabled'), '0' => t('Disabled')); - $form['access'] = array( - '#type' => 'fieldset', - '#title' => t('Access log settings')); - $form['access']['statistics_enable_access_log'] = array( - '#type' => 'radios', - '#title' => t('Enable access log'), - '#default_value' => variable_get('statistics_enable_access_log', 0), - '#options' => $options, - '#description' => t('Log each page access. Required for referrer statistics.')); - $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); - $form['access']['statistics_flush_accesslog_timer'] = array( - '#type' => 'select', - '#title' => t('Discard access logs older than'), - '#default_value' => variable_get('statistics_flush_accesslog_timer', 259200), - '#options' => $period, - '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. Requires crontab.')); - - // count content views settings - $form['content'] = array( - '#type' => 'fieldset', - '#title' => t('Content viewing counter settings')); - $form['content']['statistics_count_content_views'] = array( - '#type' => 'radios', - '#title' => t('Count content views'), - '#default_value' => variable_get('statistics_count_content_views', 0), - '#options' => $options, - '#description' => t('Increment a counter each time content is viewed.')); - - return system_settings_form($form); -} - /** * Implementation of hook_cron(). */ @@ -577,5 +323,3 @@ function statistics_nodeapi(&$node, $op, $arg = 0) { db_query('DELETE FROM {node_counter} WHERE nid = %d', $node->nid); } } - - diff --git a/modules/statistics/statistics.pages.inc b/modules/statistics/statistics.pages.inc new file mode 100644 index 000000000..c2358285a --- /dev/null +++ b/modules/statistics/statistics.pages.inc @@ -0,0 +1,71 @@ +<?php +// $Id$ + +/** + * @file + * User page callbacks for the statistics module. + */ + +function statistics_node_tracker() { + if ($node = node_load(arg(1))) { + + $header = array( + array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'), + array('data' => t('Referrer'), 'field' => 'a.url'), + array('data' => t('User'), 'field' => 'u.name'), + array('data' => t('Operations'))); + + $result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\''. tablesort_sql($header), 30, 0, NULL, $node->nid); + $rows = array(); + while ($log = db_fetch_object($result)) { + $rows[] = array( + array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), + _statistics_link($log->url), + theme('username', $log), + l(t('details'), "admin/logs/access/$log->aid")); + } + + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4)); + } + + drupal_set_title(check_plain($node->title)); + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; + } + else { + drupal_not_found(); + } +} + +function statistics_user_tracker() { + if ($account = user_load(array('uid' => arg(1)))) { + + $header = array( + array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'), + array('data' => t('Page'), 'field' => 'path'), + array('data' => t('Operations'))); + + $result = pager_query('SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d'. tablesort_sql($header), 30, 0, NULL, $account->uid); + $rows = array(); + while ($log = db_fetch_object($result)) { + $rows[] = array( + array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), + _statistics_format_item($log->title, $log->path), + l(t('details'), "admin/logs/access/$log->aid")); + } + + if (empty($rows)) { + $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3)); + } + + drupal_set_title(check_plain($account->name)); + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; + } + else { + drupal_not_found(); + } +} |