You are here

function nodequeue_queue_form in Nodequeue 5

Add or edit a queue.

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

File

./nodequeue.module, line 279

Code

function nodequeue_queue_form($queue = NULL) {
  if (!$queue) {
    $queue = new stdClass();
  }
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $queue->title,
    '#size' => 50,
    '#maxlength' => 64,
    '#description' => t('Enter the name of the queue'),
  );
  $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['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.'),
  );
  $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 * FROM {role} ORDER BY 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.'),
  );
  foreach (node_get_types() as $type => $info) {
    $nodes[$type] = $info->name;
  }
  $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[] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  if ($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,
    );
  }
  return $form;
}