You are here

function nodequeue_node_delete in Nodequeue 7.2

Same name and namespace in other branches
  1. 7.3 nodequeue.module \nodequeue_node_delete()

Implements hook_node_delete.

File

./nodequeue.module, line 308
Maintains queues of nodes in arbitrary order.

Code

function nodequeue_node_delete($node) {

  // If a node is being deleted, ensure it's also removed from any queues.
  $result = db_query("SELECT qid, sqid FROM {nodequeue_nodes} WHERE nid =:nid", array(
    ':nid' => $node->nid,
  ));
  foreach ($result as $obj) {

    // If the queue is being tracked by translation set and the node is part
    // of a translation set, don't delete the queue record.
    // Instead, data will be updated in the 'translation_change' op, below.
    $queues = nodequeue_load_queues(array(
      $obj->qid,
    ));
    $queue = array_shift($queues);
    if (!$queue->i18n || isset($node->tnid) && empty($node->tnid)) {

      // This removes by nid, not position, because if we happen to have a
      // node in a queue twice, the 2nd position would be wrong.
      nodequeue_subqueue_remove_node($obj->sqid, $node->nid);
    }
    if (module_exists('rules')) {
      rules_invoke_event('nodequeue_node_changed', nodequeue_load_subqueue($obj->sqid), $node);
    }
  }
}