function nodequeue_subqueue_shuffle in Nodequeue 5.2
Same name and namespace in other branches
- 6.2 nodequeue.module \nodequeue_subqueue_shuffle()
- 7.3 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.
1 call to nodequeue_subqueue_shuffle()
- nodequeue_arrange_subqueue_form_submit in ./
nodequeue.module - Submit function for nodequeue_arrange_subqueue_form
File
- ./
nodequeue.module, line 2147
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));
}
}