? css
? favicon.ico
? files
? i145353.patch
? img
? index.html
? term_node_forum.patch
? test
? sites/all/modules
? sites/default/settings.php
Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.7
diff -u -p -r1.7 forum.install
--- modules/forum/forum.install	25 May 2007 12:46:44 -0000	1.7
+++ modules/forum/forum.install	2 Jun 2007 23:22:32 -0000
@@ -9,6 +9,15 @@ function forum_install() {
   drupal_install_schema('forum');
 }
 
+function forum_update_6001() {
+  $ret = array();
+    if (db_table_exists('forum')) {
+      db_drop_index($ret, 'forum_topic', 'nid'); 
+      db_add_index($ret, 'forum_topic', array('nid', 'tid'));
+  }
+  return $ret;
+}
+
 /**
  * Implementation of hook_uninstall().
  */
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.400
diff -u -p -r1.400 forum.module
--- modules/forum/forum.module	30 May 2007 08:04:38 -0000	1.400
+++ modules/forum/forum.module	2 Jun 2007 23:22:32 -0000
@@ -322,7 +322,7 @@ function forum_view(&$node, $teaser = FA
     // Breadcrumb navigation
     $breadcrumb = array();
     $breadcrumb[] = array('path' => 'forum', 'title' => $vocabulary->name);
-    if ($parents = taxonomy_get_parents_all($node->tid)) {
+    if ($parents = taxonomy_get_parents_all($node->taxonomy[_forum_get_vid()])) {
       $parents = array_reverse($parents);
       foreach ($parents as $p) {
         $breadcrumb[] = array('path' => 'forum/'. $p->tid, 'title' => $p->name);
@@ -402,10 +402,10 @@ function forum_validate($node) {
  */
 function forum_update($node) {
   if ($node->revision) {
-    db_query("INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $node->tid);
+    db_query("INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $node->taxonomy[_forum_get_vid()]);
   }
   else {
-    db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->tid, $node->vid);
+    db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->taxonomy[_forum_get_vid()], $node->vid);
   }
 }
 
@@ -446,7 +446,7 @@ function forum_prepare(&$node) {
  * Implementation of hook_insert().
  */
 function forum_insert($node) {
-  db_query('INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $node->tid);
+  db_query('INSERT INTO {forum} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $node->taxonomy[_forum_get_vid()]);
 }
 
 /**
@@ -765,7 +765,7 @@ function forum_get_forums($tid = 0) {
 
     $counts = array();
 
-    $sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.status = 1 AND n.type = 'forum' GROUP BY r.tid";
+    $sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {forum} r ON n.nid = r.nid WHERE n.status = 1 GROUP BY r.tid";
     $sql = db_rewrite_sql($sql);
     $_counts = db_query($sql);
     while ($count = db_fetch_object($_counts)) {
@@ -790,7 +790,7 @@ function forum_get_forums($tid = 0) {
     // This query does not use full ANSI syntax since MySQL 3.x does not support
     // table1 INNER JOIN table2 INNER JOIN table3 ON table2_criteria ON table3_criteria
     // used to join node_comment_statistics to users.
-    $sql = "SELECT ncs.last_comment_timestamp, IF (ncs.last_comment_uid != 0, u2.name, ncs.last_comment_name) AS last_comment_name, ncs.last_comment_uid FROM {node} n INNER JOIN {users} u1 ON n.uid = u1.uid INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {users} u2 ON ncs.last_comment_uid=u2.uid WHERE n.status = 1 AND n.type='forum' AND tn.tid = %d ORDER BY ncs.last_comment_timestamp DESC";
+    $sql = "SELECT ncs.last_comment_timestamp, IF (ncs.last_comment_uid != 0, u2.name, ncs.last_comment_name) AS last_comment_name, ncs.last_comment_uid FROM {node} n INNER JOIN {users} u1 ON n.uid = u1.uid INNER JOIN {forum} tn ON n.nid = tn.nid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {users} u2 ON ncs.last_comment_uid=u2.uid WHERE n.status = 1 AND tn.tid = %d ORDER BY ncs.last_comment_timestamp DESC";
     $sql = db_rewrite_sql($sql);
     $topic = db_fetch_object(db_query_range($sql, $forum->tid, 0, 1));
 
@@ -813,7 +813,7 @@ function forum_get_forums($tid = 0) {
  * than NODE_NEW_LIMIT.
  */
 function _forum_topics_unread($term, $uid) {
-  $sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid AND tn.tid = %d LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.type = 'forum' AND n.created > %d AND h.nid IS NULL";
+  $sql = "SELECT COUNT(*) FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid AND f.tid = %d LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.created > %d AND h.nid IS NULL";
   $sql = db_rewrite_sql($sql);
   return db_result(db_query($sql, $term, $uid, NODE_NEW_LIMIT));
 }
@@ -838,11 +838,11 @@ function forum_get_topics($tid, $sortby,
 
   $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_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f, {node} n 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, 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_comment_statistics} l, {users} cu, {users} u, {forum} f, {node} n WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = f.nid AND f.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.
 
-  $sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum'");
+  $sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {forum} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1");
 
   $result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid);
   $topics = array();
@@ -883,7 +883,7 @@ function forum_get_topics($tid, $sortby,
 function _forum_new($tid) {
   global $user;
 
-  $sql = "SELECT n.nid FROM {node} n LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' AND h.nid IS NULL AND n.created > %d ORDER BY created";
+  $sql = "SELECT n.nid FROM {node} n LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {forum} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND h.nid IS NULL AND n.created > %d ORDER BY created";
   $sql = db_rewrite_sql($sql);
   $nid = db_result(db_query_range($sql, $user->uid, $tid, NODE_NEW_LIMIT, 0, 1));
 
@@ -1110,8 +1110,8 @@ function theme_forum_topic_navigation($n
   $output = '';
 
   // get previous and next topic
-  $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
-  $result = db_query(db_rewrite_sql($sql), isset($node->tid) ? $node->tid : 0);
+  $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {forum} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
+  $result = db_query(db_rewrite_sql($sql), isset($node->taxonomy[_forum_get_vid()]) ? $node->taxonomy[_forum_get_vid()] : 0);
 
   $stop = 0;
   while ($topic = db_fetch_object($result)) {
Index: modules/forum/forum.schema
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.schema,v
retrieving revision 1.1
diff -u -p -r1.1 forum.schema
--- modules/forum/forum.schema	25 May 2007 12:46:44 -0000	1.1
+++ modules/forum/forum.schema	2 Jun 2007 23:22:32 -0000
@@ -9,12 +9,11 @@ function forum_schema() {
       'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
     ),
     'indexes' => array(
-      'nid' => array('nid'),
-      'tid' => array('tid')
+      'tid' => array('tid'),
+      'forum_topic' => array('nid','tid'),
     ),
     'primary key' => array('vid'),
   );
 
   return $schema;
-}
-
+}
\ No newline at end of file
