function nodequeue_add_action in Nodequeue 5.2
Same name and namespace in other branches
- 6.2 nodequeue.module \nodequeue_add_action()
- 7.3 includes/nodequeue.actions.inc \nodequeue_add_action()
- 7.2 includes/nodequeue.actions.inc \nodequeue_add_action()
Action to add a node to a queue.
File
- ./
nodequeue.actions.inc, line 76 - nodequeue.actions.inc Provides actions integration for node queues.
Code
function nodequeue_add_action($node, $context) {
$queues = nodequeue_load_queues($context['qids'], TRUE);
// Filter out queues by node type. We choose not to use nodequeue_get_qids() because it checks for access control which only matters if we administering a queue.
$eligible_queues = array();
foreach ($queues as $queue) {
if (in_array($node->type, $queue->types)) {
$eligible_queues[$queue->qid] = $queue;
}
}
if (!empty($eligible_queues)) {
// Remove the node from the eligible queues (if needed).
nodequeue_remove_action($node, array(
'qids' => array_keys($eligible_queues),
));
// Use API to get the eligible subqueues
$eligible_subqueues = nodequeue_get_subqueues_by_node($eligible_queues, $node);
// Add node to each subqueue.
foreach ($eligible_subqueues as $subqueue) {
nodequeue_subqueue_add($queues[$subqueue->qid], $subqueue, $node->nid);
}
}
}