You are here

function nodequeue_subqueue_remove in Nodequeue 6.2

Same name and namespace in other branches
  1. 5.2 nodequeue.module \nodequeue_subqueue_remove()
  2. 7.3 nodequeue.module \nodequeue_subqueue_remove()
  3. 7.2 nodequeue.module \nodequeue_subqueue_remove()

Remove a node or node(s) from a nodequeue by position.

If you know the nid but but not the position, use

Parameters

$sqid: The subqueue to remove nodes from.

$start: The first position (starting from 1) to remove.

$end: The last position to remove. If NULL or equal to $start, only one node will be removed. Thus if $start is 1 and $end is 2, the first and second items will be removed from the queue.

See also

nodequeue_subqueue_remove_node() instead.

4 calls to nodequeue_subqueue_remove()
NodequeueAPISubqueueUnitTest::testNodequeueSubqueueRemove in tests/nodequeue.test
nodequeue_admin_remove in includes/nodequeue.admin.inc
Page callback to remove an item from a queue. This will be used only if javascript is disabled in the client, and is a fallback technique. This differs from nodequeue_admin_remove_node in that it removes a specific position, which is necessary in case…
nodequeue_check_subqueue_size in ./nodequeue.module
Guarantee that a subqueue has not gotten too big. It's important to call this after an operation that might have reduced a queue's maximum size. It stores the count to save a query if this is to be followed by an add operation.
nodequeue_subqueue_remove_node in ./nodequeue.module
Remove a node from the queue. If a node is in the queue more than once, only the first (closest to 0 position, or the front of the queue) will be removed.

File

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

Code

function nodequeue_subqueue_remove($sqid, $start, $end = NULL) {
  if (!isset($end)) {
    $end = $start;
  }

  // Retrieve the nodes that are being removed.
  $result = db_query("SELECT nid FROM {nodequeue_nodes} WHERE sqid = %d AND position >= %d AND position <= %d", $sqid, $start, $end);
  $diff = $end - $start + 1;
  db_query("DELETE FROM {nodequeue_nodes} WHERE sqid = %d AND position >= %d AND position <= %d", $sqid, $start, $end);
  db_query("UPDATE {nodequeue_nodes} SET position = position - %d WHERE sqid = %d AND position > %d", $diff, $sqid, $end);

  // Invoke the hook to let other modules know that the nodes were removed.
  while ($node = db_fetch_object($result)) {
    module_invoke_all('nodequeue_remove', $sqid, $node->nid);
  }
}