You are here

function apachesolr_exclude_node_node_update in Apache Solr Exclude Node 7

Implements hook_node_update().

File

./apachesolr_exclude_node.module, line 90
Module file for the Apache Solr Exclude Node module.

Code

function apachesolr_exclude_node_node_update($node) {

  // If the user created a new revision will we insert a new record in the db.
  // Else update database if we need to exclude the node.
  // Otherwise we delete the record from the database.
  if (!$node->is_new && !empty($node->revision) && $node->vid) {
    apachesolr_exclude_node_node_insert($node);
  }
  elseif (!empty($node->apachesolr_exclude_node_enabled)) {
    db_merge('apachesolr_exclude_node')
      ->key(array(
      'vid' => $node->vid,
    ))
      ->fields(array(
      'nid' => $node->nid,
      'exclude' => $node->apachesolr_exclude_node_enabled ? 1 : 0,
    ))
      ->execute();
  }
  else {
    apachesolr_exclude_node_node_revision_delete($node);
  }
}