function forum_submit in Drupal 5
Same name and namespace in other branches
- 4 modules/forum.module \forum_submit()
Implementation of hook_submit().
Check in particular that only a "leaf" term in the associated taxonomy vocabulary is selected, not a "container" term.
File
- modules/
forum/ forum.module, line 321 - Enable threaded discussions about general topics.
Code
function forum_submit(&$node) {
// Make sure all fields are set properly:
$node->icon = !empty($node->icon) ? $node->icon : '';
if ($node->taxonomy) {
// 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 (in_array($term, $forum_terms)) {
$node->tid = $term;
}
}
$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;
}
}
}
}