--- modules/tracker/tracker.module.orig	Sat Dec  9 12:38:49 2006
+++ modules/tracker/tracker.module	Sat Dec  9 12:16:00 2006
@@ -76,15 +76,32 @@
   // Add CSS
   drupal_add_css(drupal_get_path('module', 'tracker') .'/tracker.css');
 
+  $view_comments = module_exists('comment') && user_access('access comments');
+
   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 = %d 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 = %d 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, COMMENT_PUBLISHED, $uid, $uid);
+    // Different SQL code whether the comment module is enabled or not
+    if ($view_comments) {
+      $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, COALESCE(l.last_comment_timestamp, n.changed) AS last_post, l.comment_count FROM {node} n LEFT 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_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 = %d 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, COMMENT_PUBLISHED, $uid, $uid);
+    } 
+    else {
+      $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, n.changed AS last_post FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND (n.uid = %d) ORDER BY last_post DESC';
+      $sql = db_rewrite_sql($sql);
+      $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n WHERE n.status = 1 AND n.uid = %d';
+      $sql_count = db_rewrite_sql($sql_count);
+      $result = pager_query($sql, 25, 0, $sql_count, $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';
+    if ($view_comments) {
+      $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, COALESCE(l.last_comment_timestamp, n.changed) AS last_post, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_post DESC';
+    } 
+    else {
+      $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, n.changed AS last_post FROM {node} n INNER JOIN {users} u ON n.uid = u.uid 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);
@@ -95,7 +112,7 @@
   while ($node = db_fetch_object($result)) {
     // Determine the number of comments:
     $comments = 0;
-    if (module_exists('comment') && $node->comment_count) {
+    if ($view_comments && $node->comment_count) {
       $comments = $node->comment_count;
 
       if ($new = comment_num_new($node->nid)) {
@@ -104,20 +121,28 @@
       }
     }
 
-    $rows[] = array(
-      node_get_types('name', $node->type),
-      l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed)),
-      theme('username', $node),
-      array('class' => 'replies', 'data' => $comments),
-      t('@time ago', array('@time' => format_interval(time() - $node->last_post)))
-    );
+    $row = array();
+    $row[] = node_get_types('name', $node->type);
+    $row[] = l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed));
+    $row[] = theme('username', $node);
+    if ($view_comments) {
+      $row[] = array('class' => 'replies', 'data' => $comments);
+    }
+    $row[] = t('@time ago', array('@time' => format_interval(time() - $node->last_post)));
+
+    $rows[] = $row;
   }
 
   if (!$rows) {
     $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
   }
 
-  $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last post'));
+  if ($view_comments) {
+    $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last post'));
+  }
+  else {
+    $header = array(t('Type'), t('Post'), t('Author'), t('Posted'));
+  }
 
   $output = '<div id="tracker">';
   $output .= theme('table', $header, $rows);
