statistics.pages.inc

  1. drupal
    1. 6 modules/statistics/statistics.pages.inc
    2. 7 modules/statistics/statistics.pages.inc
    3. 8 core/modules/statistics/statistics.pages.inc

User page callbacks for the statistics module.

Functions & methods

NameDescription
statistics_node_tracker
statistics_user_tracker

File

modules/statistics/statistics.pages.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * User page callbacks for the statistics module.
  5. */
  6. function statistics_node_tracker() {
  7. if ($node = node_load(arg(1))) {
  8. $header = array(
  9. array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'),
  10. array('data' => t('Referrer'), 'field' => 'a.url'),
  11. array('data' => t('User'), 'field' => 'u.name'),
  12. array('data' => t('Operations')));
  13. $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
  14. $query->join('users', 'u', 'a.uid = u.uid');
  15. $query
  16. ->fields('a', array('aid', 'timestamp', 'url', 'uid'))
  17. ->fields('u', array('name'))
  18. ->condition(db_or()
  19. ->condition('a.path', 'node/' . $node->nid)
  20. ->condition('a.path', 'node/' . $node->nid . '/%', 'LIKE'))
  21. ->limit(30)
  22. ->orderByHeader($header);
  23. $result = $query->execute();
  24. $rows = array();
  25. foreach ($result as $log) {
  26. $rows[] = array(
  27. array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
  28. _statistics_link($log->url),
  29. theme('username', array('account' => $log)),
  30. l(t('details'), "admin/reports/access/$log->aid"),
  31. );
  32. }
  33. drupal_set_title($node->title);
  34. $build['statistics_table'] = array(
  35. '#theme' => 'table',
  36. '#header' => $header,
  37. '#rows' => $rows,
  38. '#empty' => t('No statistics available.'),
  39. );
  40. $build['statistics_pager'] = array('#theme' => 'pager');
  41. return $build;
  42. }
  43. else {
  44. drupal_not_found();
  45. }
  46. }
  47. function statistics_user_tracker() {
  48. if ($account = user_load(arg(1))) {
  49. $header = array(
  50. array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
  51. array('data' => t('Page'), 'field' => 'path'),
  52. array('data' => t('Operations')));
  53. $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
  54. $query
  55. ->fields('a', array('aid', 'timestamp', 'path', 'title'))
  56. ->condition('uid', $account->uid)
  57. ->limit(30)
  58. ->orderByHeader($header);
  59. $result = $query->execute();
  60. $rows = array();
  61. foreach ($result as $log) {
  62. $rows[] = array(
  63. array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
  64. _statistics_format_item($log->title, $log->path),
  65. l(t('details'), "admin/reports/access/$log->aid"));
  66. }
  67. drupal_set_title(format_username($account));
  68. $build['statistics_table'] = array(
  69. '#theme' => 'table',
  70. '#header' => $header,
  71. '#rows' => $rows,
  72. '#empty' => t('No statistics available.'),
  73. );
  74. $build['statistics_pager'] = array('#theme' => 'pager');
  75. return $build;
  76. }
  77. else {
  78. drupal_not_found();
  79. }
  80. }
Login or register to post comments