function action_nodequeue_remove in Nodequeue 5.2
Same name and namespace in other branches
- 5 nodequeue.module \action_nodequeue_remove()
- 7.3 includes/nodequeue.actions.inc \action_nodequeue_remove()
- 7.2 includes/nodequeue.actions.inc \action_nodequeue_remove()
Old-style action to remove a node from a queue.
1 call to action_nodequeue_remove()
- action_nodequeue_add in ./
nodequeue.actions.inc - Old-style action to add a node to a queue.
File
- ./
nodequeue.actions.inc, line 229 - nodequeue.actions.inc Provides actions integration for node queues.
Code
function action_nodequeue_remove($op, $edit = array(), $node) {
switch ($op) {
case 'metadata':
return array(
'description' => t('Remove from Node Queues'),
'type' => t('node'),
'batchable' => true,
'configurable' => true,
);
break;
case 'do':
$qids = $edit['qids'];
// If a node is being deleted, ensure it's also removed from any queues.
$placeholders = implode(',', array_fill(0, count($qids), '%d'));
$args = $qids;
$args[] = $node->nid;
$result = db_query("SELECT * FROM {nodequeue_nodes} WHERE qid IN ({$placeholders}) AND nid = %d", $args);
while ($obj = db_fetch_object($result)) {
// 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);
}
break;
// return an HTML config form for the action
case 'form':
// default values for form
if (!isset($edit['qids'])) {
$edit['qids'] = array();
}
$queues = nodequeue_load_queues(nodequeue_get_all_qids(500, TRUE), TRUE);
foreach ($queues as $qid => $queue) {
$options[$qid] = $queue->title;
}
// add form components
$form['qids'] = array(
'#type' => 'select',
'#title' => t("Queues"),
'#default_value' => $edit['qids'],
'#multiple' => TRUE,
'#decription' => t('Specify the queues from which the node should be removed. If the queue is a smartqueue, the node shall be removed from all subqueues.'),
'#required' => TRUE,
'#options' => $options,
);
return $form;
break;
// validate the HTML form
// process the HTML form to store configuration
case 'submit':
$params = array(
'qids' => $edit['qids'],
);
return $params;
break;
}
}