Same name and namespace in other branches
  1. 4.7.x modules/tracker.module \tracker_page()
  2. 5.x modules/tracker/tracker.module \tracker_page()
  3. 6.x modules/tracker/tracker.pages.inc \tracker_page()
  4. 7.x modules/tracker/tracker.pages.inc \tracker_page()
  5. 8.9.x core/modules/tracker/tracker.pages.inc \tracker_page()

Menu callback. Prints a listing of active nodes on the site.

1 call to tracker_page()
tracker_track_user in modules/tracker.module
Menu callback. Prints a listing of active nodes on the site.
1 string reference to 'tracker_page'
tracker_menu in modules/tracker.module
Implementation of hook_menu().

File

modules/tracker.module, line 69
Enables tracking of recent posts for users.

Code

function tracker_page($uid = 0) {
  global $user;
  $output .= '';
  if ($uid) {
    $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, 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 LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC';
    $sql = db_rewrite_sql($sql);
    $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
    $sql_count = db_rewrite_sql($sql_count);
    $result = pager_query($sql, 25, 0, $sql_count, $uid, $uid);
  }
  else {
    $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_post DESC';
    $sql = db_rewrite_sql($sql);
    $sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
    $sql_count = db_rewrite_sql($sql_count);
    $result = pager_query($sql, 25, 0, $sql_count);
  }
  while ($node = db_fetch_object($result)) {

    // Determine the number of comments:
    $comments = 0;
    if (module_exist('comment') && $node->comment_count) {
      $comments = $node->comment_count;
      if ($new = comment_num_new($node->nid)) {
        $comments .= '<br />';
        $comments .= l(t('%num new', array(
          '%num' => $new,
        )), "node/{$node->nid}", NULL, NULL, 'new');
      }
    }
    $rows[] = array(
      node_invoke($node->type, 'node_name'),
      l($node->title, "node/{$node->nid}") . ' ' . theme('mark', node_mark($node->nid, $node->changed)),
      format_name($node),
      array(
        'class' => 'replies',
        'data' => $comments,
      ),
      t('%time ago', array(
        '%time' => format_interval(time() - $node->last_post),
      )),
    );
  }
  if ($pager = theme('pager', NULL, 25, 0)) {
    $rows[] = array(
      array(
        'data' => $pager,
        'colspan' => '5',
      ),
    );
  }
  $header = array(
    t('Type'),
    t('Post'),
    t('Author'),
    t('Replies'),
    t('Last post'),
  );
  $output .= '<div id="tracker">';
  $output .= theme('table', $header, $rows);
  $output .= '</div>';
  print theme('page', $output);
}