Index: modules/forum.module
===================================================================
--- modules/forum.module	(revision 5760)
+++ modules/forum.module	(working copy)
@@ -722,13 +722,14 @@
 function forum_get_topics($tid, $sortby, $forum_per_page) {
   global $user, $forum_topic_list_header;
 
-  $forum_topic_list_header = array(
-    array('data' => '&nbsp;'),
-    array('data' => t('Topic'), 'field' => 'n.title'),
-    array('data' => t('Replies'), 'field' => 'l.comment_count'),
-    array('data' => t('Created'), 'field' => 'n.created'),
-    array('data' => t('Last reply'), 'field' => 'l.last_comment_timestamp'),
-  );
+  $forum_topic_list_header = array();
+  $forum_topic_list_header[] = array('data' => '&nbsp;');
+  $forum_topic_list_header[] = array('data' => t('Topic'), 'field' => 'n.title');
+  $forum_topic_list_header[] = array('data' => t('Replies'), 'field' => 'l.comment_count');
+  $forum_topic_list_header[] = array('data' => t('Created'), 'field' => 'n.created');
+  if (module_exist('statistics'))
+     $forum_topic_list_header[] = array('data' => t('Views'), 'field' => 'nc.totalcount');
+  $forum_topic_list_header[] = array('data' => t('Last reply'), 'field' => 'l.last_comment_timestamp');
 
   $order = _forum_get_topic_order($sortby);
   for ($i = 0; $i < count($forum_topic_list_header); $i++) {
@@ -739,7 +740,7 @@
 
   $term = taxonomy_get_term($tid);
 
-  $sql = db_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = %d AND n.uid = u.uid AND n.vid = f.vid");
+  $sql = db_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, nc.totalcount, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f LEFT JOIN {node_counter} nc ON nc.nid = n.nid WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = %d AND n.uid = u.uid AND n.vid = f.vid");
   $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,');
   $sql .= ', n.created DESC';  // Always add a secondary sort order so that the news forum topics are on top.
 
@@ -965,17 +966,19 @@
         $rows[] = array(
           array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
           array('data' => check_plain($topic->title), 'class' => 'title'),
-          array('data' => l(t('This topic has been moved'), "forum/$topic->tid"), 'colspan' => '3')
+          array('data' => l(t('This topic has been moved'), "forum/$topic->tid"), 'colspan' => module_exist('statistics') ? '4': '3')
         );
       }
       else {
-        $rows[] = array(
-          array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
-          array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
-          array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
-          array('data' => _forum_format($topic), 'class' => 'created'),
-          array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply')
-        );
+        $row = array();
+        $row[] = array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon');
+        $row[] = array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic');
+        $row[] = array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies');
+        $row[] = array('data' => _forum_format($topic), 'class' => 'created');
+        if (module_exist('statistics'))
+           $row[] = array('data' => $topic->totalcount, 'class' => 'views');
+        $row[] = array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply');
+        $rows[] = $row;
       }
     }
   }
