/[drupal]/drupal/modules/statistics/statistics.pages.inc
ViewVC logotype

Contents of /drupal/modules/statistics/statistics.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.20 - (show annotations) (download) (as text)
Sun Nov 1 21:26:44 2009 UTC (3 weeks, 2 days ago) by webchick
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, HEAD
Changes since 1.19: +2 -2 lines
File MIME type: text/x-php
#192056 by effulgentsia, Dave Cohen, andypost, hswong3i, geodaniel, pwolanin, and dahacouk: Ensure user's raw login name is never output directly.
1 <?php
2 // $Id: statistics.pages.inc,v 1.19 2009/10/29 07:17:22 webchick Exp $
3
4 /**
5 * @file
6 * User page callbacks for the statistics module.
7 */
8
9 function statistics_node_tracker() {
10 if ($node = node_load(arg(1))) {
11
12 $header = array(
13 array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'),
14 array('data' => t('Referrer'), 'field' => 'a.url'),
15 array('data' => t('User'), 'field' => 'u.name'),
16 array('data' => t('Operations')));
17
18 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
19 $query->join('users', 'u', 'a.uid = u.uid');
20
21 $query
22 ->fields('a', array('aid', 'timestamp', 'url', 'uid'))
23 ->fields('u', array('name'))
24 ->condition(db_or()
25 ->condition('a.path', 'node/' . $node->nid)
26 ->condition('a.path', 'node/' . $node->nid . '/%', 'LIKE'))
27 ->limit(30)
28 ->orderByHeader($header);
29
30 $result = $query->execute();
31 $rows = array();
32 foreach ($result as $log) {
33 $rows[] = array(
34 array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
35 _statistics_link($log->url),
36 theme('username', array('account' => $log)),
37 l(t('details'), "admin/reports/access/$log->aid"),
38 );
39 }
40
41 if (empty($rows)) {
42 $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
43 }
44
45 drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
46 $build['statistics_table'] = array(
47 '#theme' => 'table',
48 '#header' => $header,
49 '#rows' => $rows
50 );
51 $build['statistics_pager'] = array('#theme' => 'pager');
52 return $build;
53 }
54 else {
55 drupal_not_found();
56 }
57 }
58
59 function statistics_user_tracker() {
60 if ($account = user_load(arg(1))) {
61
62 $header = array(
63 array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
64 array('data' => t('Page'), 'field' => 'path'),
65 array('data' => t('Operations')));
66 $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
67 $query
68 ->fields('a', array('aid', 'timestamp', 'path', 'title'))
69 ->condition('uid', $account->uid)
70 ->limit(30)
71 ->orderByHeader($header);
72
73 $result = $query->execute();
74 $rows = array();
75 foreach ($result as $log) {
76 $rows[] = array(
77 array('data' => format_date($log->timestamp, 'short'), 'class' => array('nowrap')),
78 _statistics_format_item($log->title, $log->path),
79 l(t('details'), "admin/reports/access/$log->aid"));
80 }
81
82 if (empty($rows)) {
83 $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3));
84 }
85
86 drupal_set_title(format_username($account));
87 $build['statistics_table'] = array(
88 '#theme' => 'table',
89 '#header' => $header,
90 '#rows' => $rows
91 );
92 $build['statistics_pager'] = array('#theme' => 'pager');
93 return $build;
94 }
95 else {
96 drupal_not_found();
97 }
98 }

  ViewVC Help
Powered by ViewVC 1.1.2