You are here

function forum_access_node_presave in Forum Access 7

Implements hook_node_presave().

2 string references to 'forum_access_node_presave'
forum_access_node_insert in ./forum_access.module
Implements hook_node_insert().
forum_access_node_update in ./forum_access.module
Implements hook_node_update().

File

./forum_access.module, line 397
forum_access.module

Code

function forum_access_node_presave($node, $return_old_tid = FALSE) {
  $old_tid =& drupal_static('forum_access_node_presave');
  if (_forum_node_check_node_type($node)) {
    if (empty($node->nid)) {

      // Added for migrations, which log errors due to no nid during presave, see #3003279.
      $old_tid = NULL;
    }
    else {
      $old_tid = db_query('SELECT tid FROM {forum} WHERE nid = :nid', array(
        ':nid' => $node->nid,
      ))
        ->fetchField();
    }
  }
  if (!empty($old_tid) && empty($node->taxonomy_forums['und'])) {
    $node->forum_tid = null;
  }
}