function nodequeue_generate_repopulate_queues in Nodequeue 7.3
Same name and namespace in other branches
- 7.2 nodequeue_generate.module \nodequeue_generate_repopulate_queues()
Re-populates nodequeues with nodes.
Parameters
$queues Array of queues, that need to be repopulated.:
3 calls to nodequeue_generate_repopulate_queues()
- drush_nodequeue_generate in ./
nodequeue_generate.drush.inc - Re-populates specified nodequeues with random nodes.
- drush_nodequeue_generate_all in ./
nodequeue_generate.drush.inc - Re-populates all nodequeues with random nodes.
- nodequeue_generate_form_submit in ./
nodequeue_generate.module
File
- ./
nodequeue_generate.module, line 94
Code
function nodequeue_generate_repopulate_queues($queues, $nodes_limit = 10) {
// Remove existing nodes from queues.
db_query("DELETE FROM {nodequeue_nodes} WHERE name IN (:queues)", array(
':queues' => $queues,
));
// Load all queues and their subqueues.
$queues = nodequeue_load_queues($queues);
// Re-populate subqueues
foreach ($queues as $queue) {
// Skip nodequeues that do not belong to any node types.
if (!empty($queue->types)) {
$limit = $queue->size ? $queue->size : $nodes_limit;
$callback = $queue->owner . '_nodequeue_generate';
if (function_exists($callback)) {
$callback($queue, $limit);
}
}
}
drupal_set_message(format_plural(count($queues), '1 queue populated', '@count queues populated.'));
}