You are here

function nodequeue_view_queues in Nodequeue 5.2

Same name and namespace in other branches
  1. 6.2 includes/nodequeue.admin.inc \nodequeue_view_queues()
  2. 7.3 includes/nodequeue.admin.inc \nodequeue_view_queues()
  3. 7.2 includes/nodequeue.admin.inc \nodequeue_view_queues()

Display a list of queues and their status for the administrator.

1 string reference to 'nodequeue_view_queues'
nodequeue_menu in ./nodequeue.module
Implementation of hook_menu

File

./nodequeue.module, line 453

Code

function nodequeue_view_queues() {

  // Fetch all of the queues.
  $queues = nodequeue_load_queues(nodequeue_get_all_qids(25));
  foreach ($queues as $queue) {
    if (!nodequeue_queue_access($queue)) {
      unset($queues[$queue->qid]);
    }
  }
  if (empty($queues)) {
    return t('No node queues exist.');
  }
  $qids = array();

  // For every queue that has exactly 1 subqueue,
  foreach ($queues as $queue) {
    if ($queue->subqueues == 1) {
      $qids[] = $queue->qid;
    }
  }
  $subqueues = nodequeue_load_subqueues_by_queue($qids);

  // Relate all the subqueues we loaded back to our queues.
  foreach ($subqueues as $subqueue) {
    if (nodequeue_api_subqueue_access($subqueue, NULL, $queues[$subqueue->qid])) {
    }
    $queues[$subqueue->qid]->subqueue = $subqueue;
  }
  $header = array(
    t('Title'),
    t('Max nodes'),
    t('Subqueues'),
    t('Operation'),
  );
  $rows = array();
  foreach ($queues as $queue) {
    $sub_text = $queue->subqueues;
    if ($sub_text == 1) {
      $sub_text .= " (" . nodequeue_subqueue_size_text($queue->size, $queue->subqueue->count) . ")";
    }
    $operations = array(
      l(t('View'), "admin/content/nodequeue/{$queue->qid}/view"),
    );
    if (user_access('administer nodequeue')) {
      $operations[] = l(t('Edit'), "admin/content/nodequeue/{$queue->qid}/edit");
      $operations[] = l(t('Delete'), "admin/content/nodequeue/{$queue->qid}/delete");
    }
    $rows[] = array(
      array(
        'class' => 'nodequeue-title',
        'data' => check_plain($queue->title),
      ),
      array(
        'class' => 'nodequeue-max-nodes',
        'data' => $queue->size == 0 ? t('Infinite') : $queue->size,
      ),
      array(
        'class' => 'nodequeue-subqueues',
        'data' => $sub_text,
      ),
      array(
        'class' => 'nodequeue-operation',
        'data' => implode(' | ', $operations),
      ),
    );
  }
  $output = theme('table', $header, $rows);
  $output .= theme('pager', NULL, 25);
  return $output;
}