You are here

function _apachesolr_nodeapi_update in Apache Solr Search 6

Same name and namespace in other branches
  1. 5.2 apachesolr.module \_apachesolr_nodeapi_update()

Helper function for hook_nodeapi().

1 call to _apachesolr_nodeapi_update()
apachesolr_nodeapi in ./apachesolr.module
Implementation of hook_nodeapi().

File

./apachesolr.module, line 629
Integration with the Apache Solr search application.

Code

function _apachesolr_nodeapi_update($node, $set_message = TRUE) {

  // Check if the node has gone from published to unpublished.
  if (!$node->status && db_result(db_query("SELECT status FROM {apachesolr_search_node} WHERE nid = %d", $node->nid))) {
    if (apachesolr_delete_node_from_index($node)) {

      // There was no exception, so update the table.
      db_query('UPDATE {apachesolr_search_node} SET changed = %d, status = %d WHERE nid = %d', time(), $node->status, $node->nid);
      if ($set_message && user_access('administer search') && variable_get('apachesolr_set_nodeapi_messages', 1)) {
        apachesolr_set_stats_message('Unpublished content will be removed from the Apache Solr search index in approximately @autocommit_time.');
      }
    }
  }
  else {
    db_query('UPDATE {apachesolr_search_node} SET changed = %d, status = %d WHERE nid = %d', time(), $node->status, $node->nid);
  }
}