forum_node_update

Versions
7
forum_node_update($node)

Implement hook_node_update().

Code

modules/forum/forum.module, line 248

<?php
function forum_node_update($node) {
  if (_forum_node_check_node_type($node)) {
    if (empty($node->revision) && db_query('SELECT tid FROM {forum} WHERE nid=:nid', array(':nid' => $node->nid))->fetchField()) {
      if (!empty($node->forum_tid)) {
        db_update('forum')
          ->fields(array('tid' => $node->forum_tid))
          ->condition('vid', $node->vid)
          ->execute();
      }
      // The node is removed from the forum.
      else {
        db_delete('forum')
          ->condition('nid', $node->nid)
          ->execute();
      }
    }
    else {
      if (!empty($node->forum_tid)) {
        db_insert('forum')
          ->fields(array(
            'tid' => $node->forum_tid,
            'vid' => $node->vid,
            'nid' => $node->nid,
          ))
          ->execute();
      }
    }
    // If the node has a shadow forum topic, update the record for this
    // revision.
    if ($node->shadow) {
      db_delete('forum')
        ->condition('nid', $node->nid)
        ->condition('vid', $node->vid)
        ->execute();
      db_insert('forum')
        ->fields(array(
          'nid' => $node->nid,
          'vid' => $node->vid,
          'tid' => $node->forum_tid,
        ))
        ->execute();
     }
  }
}
?>
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.