function nodequeue_subqueue_shuffle in Nodequeue 7.3
Same name and namespace in other branches
- 5.2 nodequeue.module \nodequeue_subqueue_shuffle()
- 6.2 nodequeue.module \nodequeue_subqueue_shuffle()
- 7.2 nodequeue.module \nodequeue_subqueue_shuffle()
Shuffle a queue.
Parameters
$subqueue: The subqueue to shuffle. May be a sqid or the loaded object.
File
- ./
nodequeue.module, line 1377 - Maintains queues of nodes in arbitrary order.
Code
function nodequeue_subqueue_shuffle($subqueue) {
// Load the queue
if (!is_object($subqueue)) {
$subqueue = nodequeue_load_subqueue($subqueue);
}
if (empty($subqueue)) {
return;
}
$count = $subqueue->count;
// Swap each item with another randomly picked one.
foreach (range(1, $count) as $i) {
nodequeue_queue_swap($subqueue, $i, rand(1, $count));
}
}