You are here

function nodequeue_edit_queue_form in Nodequeue 5.2

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

Add or edit a queue.

1 call to nodequeue_edit_queue_form()
nodequeue_workflow_ng_action_add_nodequeue_form in ./nodequeue.workflow_ng.inc
1 string reference to 'nodequeue_edit_queue_form'
nodequeue_menu in ./nodequeue.module
Implementation of hook_menu

File

./nodequeue.module, line 539

Code

function nodequeue_edit_queue_form($queue) {

  // For adding queues.
  if (is_string($queue)) {
    $queue = new nodequeue_queue($queue);
  }
  $info = nodequeue_api_info();
  $form['description'] = array(
    '#type' => 'fieldset',
    '#title' => $info[$queue->owner]['title'],
    '#description' => $info[$queue->owner]['description'],
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $queue->title,
    '#size' => 50,
    '#maxlength' => 64,
    '#description' => t('Enter the name of the queue'),
  );

  // This is a value; as the default nodequeue implementation has just one
  // queue per nodequeue, this field is totally redundant. Plugins can
  // override this.
  $form['subqueue_title'] = array(
    '#type' => 'value',
    '#value' => $queue->subqueue_title,
  );

  // The placeholder is put here so that modifiers have an easy way to put
  // additional form widgets in a prominent spot but not before the title of
  // the queue.
  $form['placeholder'] = array();
  $form['size'] = array(
    '#type' => 'textfield',
    '#title' => t('Queue size'),
    '#default_value' => $queue->size,
    '#size' => 2,
    '#maxlength' => 2,
    '#description' => t('The maximum number of nodes will appear in the queue. Enter 0 for no limit'),
  );
  $form['reverse'] = array(
    '#type' => 'checkbox',
    '#title' => t('Reverse in admin view'),
    '#default_value' => $queue->reverse,
    '#description' => t('Ordinarily queues are arranged with the front of the queue (where items will be removed) on top and the back (where items will be added) on the bottom. If checked, this will display the queue such that items will be added to the top and removed from the bottom.'),
  );
  $form['link'] = array(
    '#type' => 'textfield',
    '#title' => t('Link "add to queue" text'),
    '#default_value' => $queue->link,
    '#size' => 40,
    '#maxlength' => 40,
    '#description' => t('If you want a link to add a node to a queue in the "links" section (next to "add new comment"), enter the text here. If left blank no link will be given; note that enabling this feature for any queue will cause an extra query to be run every time a node is loaded. "%subqueue" will be replaced with the subqueue title, if applicable.'),
  );
  $form['link_remove'] = array(
    '#type' => 'textfield',
    '#title' => t('Link "remove from queue" text'),
    '#default_value' => $queue->link_remove,
    '#size' => 40,
    '#maxlength' => 40,
    '#description' => t('Enter the text for the corresponding link to remove a node from a queue. This may be blank (in which case no link will appear) but a remove link will only appear if link, above, is set.'),
  );
  $result = db_query("SELECT r.* FROM {role} r LEFT JOIN {permission} p ON p.rid = r.rid WHERE p.perm LIKE '%manipulate queues%' ORDER BY r.name");
  while ($role = db_fetch_object($result)) {
    $roles[$role->rid] = $role->name;
  }
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => $queue->roles,
    '#options' => $roles,
    '#description' => t('Check each role that can add nodes to the queue. Be sure that roles you want to appear here have "manipulate queues" access in the main access control panel.'),
  );
  $nodes = node_get_types('names');
  $form['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Types'),
    '#default_value' => $queue->types,
    '#options' => $nodes,
    '#description' => t('Check each node type that can be added to this queue.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  $form['owner'] = array(
    '#type' => 'value',
    '#value' => $queue->owner,
  );
  $form['show_in_links'] = array(
    '#type' => 'value',
    '#value' => $queue->show_in_links,
  );
  $form['show_in_tab'] = array(
    '#type' => 'value',
    '#value' => $queue->show_in_tab,
  );
  $form['show_in_ui'] = array(
    '#type' => 'value',
    '#value' => $queue->show_in_ui,
  );
  $form['reference'] = array(
    '#type' => 'value',
    '#value' => $queue->reference,
  );
  $form['subqueues'] = array(
    '#type' => 'value',
    '#value' => $queue->subqueues,
  );
  if (isset($queue->qid)) {
    $form[] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
    );
    $form['qid'] = array(
      '#type' => 'value',
      '#value' => $queue->qid,
    );
    $form['count'] = array(
      '#type' => 'value',
      '#value' => $queue->count,
    );
  }
  nodequeue_api_queue_form($queue, $form);
  return $form;
}