function statistics_user_tracker

Page callback: Displays statistics for a user.

Return value

array A render array containing user statistics. If information for the user was not found, this will throw a NotFoundHttpException.

See also

statistics_menu()

1 string reference to 'statistics_user_tracker'
statistics_menu in drupal/core/modules/statistics/statistics.module
Implements hook_menu().

File

drupal/core/modules/statistics/statistics.pages.inc, line 88
User page callbacks for the Statistics module.

Code

function statistics_user_tracker() {
  if ($account = user_load(arg(1))) {
    $header = array(
      array(
        'data' => t('Timestamp'),
        'field' => 'timestamp',
        'sort' => 'desc',
      ),
      array(
        'data' => t('Page'),
        'field' => 'path',
      ),
      t('Operations'),
    );
    $query = db_select('accesslog', 'a', array(
      'target' => 'slave',
    ))
      ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
      ->extend('Drupal\\Core\\Database\\Query\\TableSortExtender');
    $query
      ->fields('a', array(
      'aid',
      'timestamp',
      'path',
      'title',
    ))
      ->condition('uid', $account->uid)
      ->limit(30)
      ->orderByHeader($header);
    $result = $query
      ->execute();
    $rows = array();
    foreach ($result as $log) {
      $row = array();
      $row[] = array(
        'data' => format_date($log->timestamp, 'short'),
        'class' => array(
          'nowrap',
        ),
      );
      $row[] = _statistics_format_item($log->title, $log->path);
      $links = array();
      $links['details'] = array(
        'title' => t('details'),
        'href' => "admin/reports/access/{$log->aid}",
      );
      $row[] = array(
        'data' => array(
          '#type' => 'operations',
          '#links' => $links,
        ),
      );
      $rows[] = $row;
    }
    drupal_set_title(user_format_name($account));
    $build['statistics_table'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#empty' => t('No statistics available.'),
    );
    $build['statistics_pager'] = array(
      '#theme' => 'pager',
    );
    return $build;
  }
  else {
    throw new NotFoundHttpException();
  }
}