From 5c57a53165f4300e90c230451663165194d0b842 Mon Sep 17 00:00:00 2001 From: Neil Drumm Date: Sat, 5 Aug 2006 01:42:56 +0000 Subject: #76339 by pwolanin, allow non-forum category changes while leaving a shadow copy --- modules/forum/forum.module | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 376c31512..d6c2f0e8e 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -323,20 +323,24 @@ function forum_submit(&$node) { $node->icon = $node->icon ? $node->icon : ''; if ($node->taxonomy) { - // Extract the node's proper topic ID. - $vocabulary = variable_get('forum_nav_vocabulary', ''); + // Get the forum terms from the (cached) tree + $tree = taxonomy_get_tree(_forum_get_vid()); + if ($tree) { + foreach ($tree as $term) { + $forum_terms[] = $term->tid; + } + } foreach ($node->taxonomy as $term) { - if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) { + if (in_array($term, $forum_terms)) { $node->tid = $term; } } - if ($node->tid && $node->shadow) { - // A shadow copy needs to be created. Retain existing term and add new term. - $terms = array_keys(taxonomy_node_get_terms($node->nid)); - if (!in_array($node->tid, $terms)) { - $terms[] = $node->tid; + $old_tid = db_result(db_query_range("SELECT tid FROM {forum} WHERE nid = %d ORDER BY vid DESC", $node->nid, 0,1)); + if ($old_tid) { + if (($node->tid != $old_tid) && $node->shadow) { + // A shadow copy needs to be created. Retain new term and add old term. + $node->taxonomy[] = $old_tid; } - $node->taxonomy = $terms; } } } -- cgit v1.2.3