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

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

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


Revision 1.28 - (show annotations) (download) (as text)
Sun Nov 1 21:26:44 2009 UTC (3 weeks, 1 day ago) by webchick
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10
Changes since 1.27: +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: tracker.pages.inc,v 1.27 2009/10/29 07:18:55 webchick Exp $
3
4 /**
5 * @file
6 * User page callbacks for the tracker module.
7 */
8
9
10 /**
11 * Menu callback; prints a listing of active nodes on the site.
12 */
13 function tracker_page($account = NULL, $set_title = FALSE) {
14 if ($account) {
15 $query = db_select('tracker_user', 't')->extend('PagerDefault');
16 $query->condition('t.uid', $account->uid);
17
18 if ($set_title) {
19 // When viewed from user/%user/track, display the name of the user
20 // as page title -- the tab title remains Track so this needs to be done
21 // here and not in the menu definition.
22 drupal_set_title(format_username($account));
23 }
24 }
25 else {
26 $query = db_select('tracker_node', 't', array('target' => 'slave'))->extend('PagerDefault');
27 }
28
29 // This array acts as a placeholder for the data selected later
30 // while keeping the correct order.
31 $nodes = $query
32 ->addTag('node_access')
33 ->fields('t', array('nid', 'changed'))
34 ->condition('t.published', 1)
35 ->orderBy('t.changed', 'DESC')
36 ->limit(25)
37 ->execute()
38 ->fetchAllAssoc('nid');
39
40 if (!empty($nodes)) {
41 // Now, get the data and put into the placeholder array
42 $result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('target' => 'slave'));
43 foreach ($result as $node) {
44 $node->last_activity = $nodes[$node->nid]->changed;
45 $nodes[$node->nid] = $node;
46 }
47
48 // Finally display the data
49 $rows = array();
50 foreach ($nodes as $node) {
51 // Determine the number of comments:
52 $comments = 0;
53 if ($node->comment_count) {
54 $comments = $node->comment_count;
55
56 if ($new = comment_num_new($node->nid)) {
57 $comments .= '<br />';
58 $comments .= l(format_plural($new, '1 new', '@count new'), 'node/'. $node->nid, array('fragment' => 'new'));
59 }
60 }
61
62 $rows[] = array(
63 check_plain(node_type_get_name($node->type)),
64 l($node->title, 'node/' . $node->nid) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
65 theme('username', array('account' => $node)),
66 array('class' => array('replies'), 'data' => $comments),
67 t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))
68 );
69 }
70 }
71 else {
72 $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
73 }
74
75 $page['tracker'] = array(
76 '#rows' => $rows,
77 '#header' => array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated')),
78 '#theme' => 'table',
79 '#attached' => array(
80 'css' => array(drupal_get_path('module', 'tracker') . '/tracker.css' => array('preprocess' => FALSE)),
81 ),
82 );
83 $page['pager'] = array(
84 '#theme' => 'pager',
85 '#quantity' => 25,
86 '#weight' => 10,
87 );
88 $page['#sorted'] = TRUE;
89
90 return $page;
91 }

  ViewVC Help
Powered by ViewVC 1.1.2