Same name and namespace in other branches
  1. 4.7.x modules/statistics.module \statistics_node_tracker()
  2. 5.x modules/statistics/statistics.module \statistics_node_tracker()
  3. 6.x modules/statistics/statistics.pages.inc \statistics_node_tracker()
  4. 7.x modules/statistics/statistics.pages.inc \statistics_node_tracker()

File

modules/statistics.module, line 163
Logs access statistics for your site.

Code

function statistics_node_tracker() {
  if ($node = node_load(array(
    'nid' => 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);
    while ($log = db_fetch_object($result)) {
      $rows[] = array(
        array(
          'data' => format_date($log->timestamp, 'small'),
          'nowrap' => 'nowrap',
        ),
        l(_statistics_column_width($log->url), $log->url),
        format_name($log),
        l(t('details'), "admin/logs/access/{$log->aid}"),
      );
    }
    if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
      $rows[] = array(
        array(
          'data' => $pager,
          'colspan' => '4',
        ),
      );
    }
    drupal_set_title(check_plain($node->title));
    print theme('page', theme('table', $header, $rows));
  }
  else {
    drupal_not_found();
  }
}