statistics.pages.inc

  1. 7.x drupal-7.x/modules/statistics/statistics.pages.inc
  2. 6.x drupal-6.x/modules/statistics/statistics.pages.inc

User page callbacks for the statistics module.

File

drupal-6.x/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. $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 = 'node/%d' OR a.path LIKE 'node/%d/%%'". tablesort_sql($header), 30, 0, NULL, $node->nid, $node->nid);
  14. $rows = array();
  15. while ($log = db_fetch_object($result)) {
  16. $rows[] = array(
  17. array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
  18. _statistics_link($log->url),
  19. theme('username', $log),
  20. l(t('details'), "admin/reports/access/$log->aid"));
  21. }
  22. if (empty($rows)) {
  23. $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
  24. }
  25. drupal_set_title(check_plain($node->title));
  26. $output = theme('table', $header, $rows);
  27. $output .= theme('pager', NULL, 30, 0);
  28. return $output;
  29. }
  30. else {
  31. drupal_not_found();
  32. }
  33. }
  34. function statistics_user_tracker() {
  35. if ($account = user_load(array('uid' => arg(1)))) {
  36. $header = array(
  37. array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
  38. array('data' => t('Page'), 'field' => 'path'),
  39. array('data' => t('Operations')));
  40. $result = pager_query('SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d'. tablesort_sql($header), 30, 0, NULL, $account->uid);
  41. $rows = array();
  42. while ($log = db_fetch_object($result)) {
  43. $rows[] = array(
  44. array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
  45. _statistics_format_item($log->title, $log->path),
  46. l(t('details'), "admin/reports/access/$log->aid"));
  47. }
  48. if (empty($rows)) {
  49. $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3));
  50. }
  51. drupal_set_title(check_plain($account->name));
  52. $output = theme('table', $header, $rows);
  53. $output .= theme('pager', NULL, 30, 0);
  54. return $output;
  55. }
  56. else {
  57. drupal_not_found();
  58. }
  59. }