00001 <?php
00002
00003
00013 function tracker_page($account = NULL, $set_title = FALSE) {
00014
00015 drupal_add_css(drupal_get_path('module', 'tracker') . '/tracker.css', 'module', 'all', FALSE);
00016
00017 if ($account) {
00018 if ($set_title) {
00019
00020
00021
00022 drupal_set_title(check_plain($account->name));
00023 }
00024
00025 $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';
00026 $sql = db_rewrite_sql($sql);
00027 $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)';
00028 $sql_count = db_rewrite_sql($sql_count);
00029 $result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid);
00030 }
00031 else {
00032 $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';
00033 $sql = db_rewrite_sql($sql);
00034 $sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
00035 $sql_count = db_rewrite_sql($sql_count);
00036 $result = pager_query($sql, 25, 0, $sql_count);
00037 }
00038
00039 $rows = array();
00040 while ($node = db_fetch_object($result)) {
00041
00042 $comments = 0;
00043 if ($node->comment_count) {
00044 $comments = $node->comment_count;
00045
00046 if ($new = comment_num_new($node->nid)) {
00047 $comments .= '<br />';
00048 $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'));
00049 }
00050 }
00051
00052 $rows[] = array(
00053 check_plain(node_get_types('name', $node->type)),
00054 l($node->title, "node/$node->nid") . ' ' . theme('mark', node_mark($node->nid, $node->changed)),
00055 theme('username', $node),
00056 array('class' => 'replies', 'data' => $comments),
00057 t('!time ago', array('!time' => format_interval(time() - $node->last_updated)))
00058 );
00059 }
00060
00061 if (!$rows) {
00062 $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
00063 }
00064
00065 $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated'));
00066
00067 $output = '<div id="tracker">';
00068 $output .= theme('table', $header, $rows);
00069 $output .= theme('pager', NULL, 25, 0);
00070 $output .= '</div>';
00071
00072 return $output;
00073 }