You are here

function nodequeue_admin_view in Nodequeue 5

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

Page callback to view a queue.

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

File

./nodequeue.module, line 450

Code

function nodequeue_admin_view($queue) {
  $qid = $queue->qid;
  $output = '';
  $output = '<p class="nodequeue-js-hide" style="display: none;">';
  $output .= t('Changes made to the queue order and queue removals will not be active until you click Save, below.');
  $output .= '</p>';
  $sql = "SELECT DISTINCT(n.nid), n.title, n.uid, u.name, n.created, nq.position FROM {node} n LEFT JOIN {users} u on n.uid = u.uid LEFT JOIN {nodequeue_nodes} nq ON nq.nid = n.nid WHERE nq.qid = {$qid} ORDER BY nq.position";

  // Don't rewrite because a queue manager has to be able to move items up
  // and down in the queue even if they can't be viewed.
  //  $sql = db_rewrite_sql($sql);
  $result = pager_query($sql, 25, 0);
  $list = array();
  $nids = array();
  if (db_num_rows($result) > 0) {
    while ($node = db_fetch_object($result)) {
      $buttons = l(theme('image', drupal_get_path('module', 'nodequeue') . '/go-up.png', t('Move up')), "admin/content/nodequeue/{$qid}/oper/up/{$node->position}", array(
        'title' => t('Move up'),
        'class' => 'nodequeue-move-up',
      ), NULL, NULL, FALSE, TRUE);
      $buttons .= l(theme('image', drupal_get_path('module', 'nodequeue') . '/go-down.png', t('Move down')), "admin/content/nodequeue/{$qid}/oper/down/{$node->position}", array(
        'title' => t('Move down'),
        'class' => 'nodequeue-move-down',
      ), NULL, NULL, FALSE, TRUE);
      $buttons .= l(theme('image', drupal_get_path('module', 'nodequeue') . '/go-top.png', t('Move to front')), "admin/content/nodequeue/{$qid}/oper/front/{$node->position}", array(
        'title' => t('Move to front'),
        'class' => 'nodequeue-move-front',
      ), NULL, NULL, FALSE, TRUE);
      $buttons .= l(theme('image', drupal_get_path('module', 'nodequeue') . '/go-bottom.png', t('Move to back')), "admin/content/nodequeue/{$qid}/oper/back/{$node->position}", array(
        'title' => t('Move to back'),
        'class' => 'nodequeue-move-back',
      ), NULL, NULL, FALSE, TRUE);
      $buttons .= l(theme('image', drupal_get_path('module', 'nodequeue') . '/user-trash.png', t('Remove from queue')), "admin/content/nodequeue/{$qid}/oper/remove/{$node->position}", array(
        'title' => t('Remove from queue'),
        'class' => 'nodequeue-remove',
      ), NULL, NULL, FALSE, TRUE);
      $list[] = array(
        'id' => 'nodequeue-row-' . $node->nid,
        'class' => 'nodequeue-row',
        'data' => array(
          l($node->title, "node/{$node->nid}"),
          theme('username', $node),
          format_date($node->created),
          $buttons,
        ),
      );
      $nids[] = $node->nid;
    }
    $header = array(
      t('Node'),
      t('Author'),
      t('Date'),
      t('Operation'),
    );
    $output .= theme('table', $header, $list, array(
      'width' => '100%',
      'id' => 'nodequeue-table',
    ));
    $output .= drupal_get_form('nodequeue_queue_admin', $qid, $nids);
    drupal_add_js(drupal_get_path('module', 'nodequeue') . '/nodequeue.js');
  }
  else {
    $output .= t('<p>Queue is empty!</p>');
  }
  return $output;
}