You are here

function smartqueue_taxonomy_nodequeue_generate in Nodequeue 7.3

Same name and namespace in other branches
  1. 7.2 nodequeue_generate.module \smartqueue_taxonomy_nodequeue_generate()

Implements hook_nodequeue_generate() for owner 'smartqueue_taxonomy'.

File

./nodequeue_generate.module, line 206

Code

function smartqueue_taxonomy_nodequeue_generate($queue, $limit) {
  $subqueues = nodequeue_load_subqueues_by_queue($queue->name);
  foreach ($subqueues as $subqueue) {
    $nodes = db_select('taxonomy_index', 'tn');
    $nodes
      ->join('node', 'n', 'n.nid=tn.nid');
    $nodes
      ->fields('n', array(
      'nid',
    ));
    $nodes
      ->condition('n.status', NODE_PUBLISHED);
    $nodes
      ->condition('n.type', $queue->types, 'IN');
    $nodes
      ->condition('tn.tid', $subqueue->reference);
    $nodes
      ->orderRandom();
    $nodes
      ->range(0, $limit);
    $nodes = $nodes
      ->execute();
    $nodes = $nodes
      ->fetchAll();
    foreach ($nodes as $node) {
      nodequeue_subqueue_add($queue, $subqueue, $node->nid);
    }
  }
}