Commit 5c57a531 authored by drumm's avatar drumm
Browse files

#76339 by pwolanin, allow non-forum category changes while leaving a shadow copy

parent 651a42b9
......@@ -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;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment