You are here

function nodequeue_machine_name_available in Nodequeue 6.2

Determine if the machine name is in use.

1 call to nodequeue_machine_name_available()
nodequeue_edit_queue_form_validate in includes/nodequeue.admin.inc
Validate function for the nodequeue_queue form.

File

./nodequeue.module, line 1893
Maintains queues of nodes in arbitrary order.

Code

function nodequeue_machine_name_available($machine_name, $qid = NULL) {

  // Find all existing records for the given machine_name
  $result = db_query("SELECT qid FROM {nodequeue_queue} WHERE `name` LIKE '%s'", $machine_name);
  $existing_queues = array();
  while ($record = db_fetch_object($result)) {
    $existing_queues[] = $record->qid;
  }
  if (count($existing_queues) == 0) {

    // Creating a new machine name queue
    return TRUE;
  }
  elseif (count($existing_queues) == 1 && !empty($qid) && $qid == $existing_queues[0]) {

    // Checking an existing queue that has not changed its name.
    return TRUE;
  }
  return FALSE;
}