forum_submit

Versions
4.7 – 5
forum_submit(&$node)

Implementation of hook_submit().

Check in particular that only a "leaf" term in the associated taxonomy vocabulary is selected, not a "container" term.

Code

modules/forum/forum.module, line 321

<?php
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;
      }
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.