[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/modules/tracker/ -> tracker.pages.inc (source)

   1  <?php
   2  
   3  /**
   4   * @file
   5   * User page callbacks for the tracker module.
   6   */
   7  
   8  
   9  /**
  10   * Menu callback. Prints a listing of active nodes on the site.
  11   */
  12  function tracker_page($account = NULL, $set_title = FALSE) {
  13    // Add CSS
  14    drupal_add_css(drupal_get_path('module', 'tracker') .'/tracker.css', 'module', 'all', FALSE);
  15  
  16    if ($account) {
  17      if ($set_title) {
  18        // When viewed from user/%user/track, display the name of the user
  19        // as page title -- the tab title remains Track so this needs to be done
  20        // here and not in the menu definiton.
  21        drupal_set_title(check_plain($account->name));
  22      }
  23    // TODO: These queries are very expensive, see http://drupal.org/node/105639
  24      $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, 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 = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
  25      $sql = db_rewrite_sql($sql);
  26      $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
  27      $sql_count = db_rewrite_sql($sql_count);
  28      $result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid);
  29    }
  30    else {
  31      $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, 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_updated DESC';
  32      $sql = db_rewrite_sql($sql);
  33      $sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
  34      $sql_count = db_rewrite_sql($sql_count);
  35      $result = pager_query($sql, 25, 0, $sql_count);
  36    }
  37  
  38    $rows = array();
  39    while ($node = db_fetch_object($result)) {
  40      // Determine the number of comments:
  41      $comments = 0;
  42      if ($node->comment_count) {
  43        $comments = $node->comment_count;
  44  
  45        if ($new = comment_num_new($node->nid)) {
  46          $comments .= '<br />';
  47          $comments .= l(format_plural($new, '1 new', '@count new'), "node/$node->nid", array('query' => comment_new_page_count($node->comment_count, $new, $node), 'fragment' => 'new'));
  48        }
  49      }
  50  
  51      $rows[] = array(
  52        check_plain(node_get_types('name', $node->type)),
  53        l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed)),
  54        theme('username', $node),
  55        array('class' => 'replies', 'data' => $comments),
  56        t('!time ago', array('!time' => format_interval(time() - $node->last_updated)))
  57      );
  58    }
  59  
  60    if (!$rows) {
  61      $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
  62    }
  63  
  64    $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated'));
  65  
  66    $output = '<div id="tracker">';
  67    $output .= theme('table', $header, $rows);
  68    $output .= theme('pager', NULL, 25, 0);
  69    $output .= '</div>';
  70  
  71    return $output;
  72  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7