? 913474_nodequeue_edit_link_permission.patch
? fix_hook_nodequeue_remove.patch
? nodequeue-286918-return.patch
? nodequeue-take5.patch
? nodequeue.module.754444.patch
? nodequeue.module.872444.patch
? nodequeue_autocomplete_slashes_0.patch
? nodequeue_dragdrop.js_.887866.patch
? nodequeue_machine_names-6.patch
? nodequeue_uninitialized_in_db_query.patch
? nodequeue_views.patch.txt
? nodequeue_views.patch.txt.1
Index: nodequeue.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodequeue/nodequeue.install,v
retrieving revision 1.22.2.1
diff -u -p -r1.22.2.1 nodequeue.install
--- nodequeue.install	11 Dec 2010 20:38:49 -0000	1.22.2.1
+++ nodequeue.install	30 Dec 2010 21:08:45 -0000
@@ -11,6 +11,11 @@ function nodequeue_schema() {
         'unsigned' => TRUE,
         'not null' => TRUE
       ),
+      'name' => array(
+        'description' => t('The machine name for the queue'),
+        'type' => 'varchar',
+        'length' => 32,
+      ),
       'title' => array(
         'description' => t('Title of a queue.'),
         'type' => 'varchar',
@@ -80,6 +85,9 @@ function nodequeue_schema() {
       ),
     ), // fields
     'primary key' => array('qid'),
+    'unique keys' => array(
+      'name' => array('name')
+    ),
   ); // nodequeue_queue.
   $schema['nodequeue_roles'] = array(
     'description' => t('Defines the roles which are allowed to use a particular nodequeue.'),
@@ -126,7 +134,7 @@ function nodequeue_schema() {
       'type' => array('type'),
     ), // indexes
   ); // nodequeue_types
-  
+
   // Subqueues are minor queues that inherit all of the properties of
   // the parent queue. A parent queue must have at least 1 subqueue
   // to do anything. Reference is for the use of whatever is creating
@@ -210,7 +218,7 @@ function nodequeue_schema() {
       'qid_nid' => array('qid', 'nid'),
     ), // indexes
   ); // nodequeue_nodes
-  
+
   return $schema;
 }
 
@@ -280,7 +288,7 @@ function nodequeue_update_5201() {
 
   // Create the nodequeue_subqueue table.
   $ret[] = update_sql("UPDATE {nodequeue_queue} SET owner = 'nodequeue', show_in_ui = 1, show_in_tab = 1, show_in_links = 1, reference = 0");
-  
+
   db_create_table($ret, 'nodequeue_subqueue', array(
     'description' => t('Subqueues are minor queues that inherit all of the properties of the parent queue. A parent queue must have at least 1 subqueue to do anything. Reference is for the use of whatever is creating the subqueues in order to link it to some other ID easily.'),
     'fields' => array(
@@ -475,6 +483,36 @@ function nodequeue_update_6006() {
   return $ret;
 }
 
+/*
+ * Provide machine names, and auto-generation of machine names for existing
+ * queues.
+ */
+function nodequeue_update_6007() {
+  $ret = array();
+  db_add_field($ret, 'nodequeue_queue', 'name', array(
+    'type' => 'varchar',
+    'length' => 32,
+  ));
+  db_add_unique_key($ret, 'nodequeue_queue', 'name', array('name'));
+
+  // Auto-generate machine names for existing queues and subqueues. Existing
+  // queues will be named "queue{$qid}" while subqueues will be named
+  // "queue{$qid}_subqueue{$sqid}"
+  global $db_type;
+
+  if ($db_type == 'mysql' || $db_type == 'mysqli') {
+    $queue_update_sql = "UPDATE {nodequeue_queue} SET name = CONCAT('queue', qid)";
+  }
+  else {
+    $queue_update_sql = "UPDATE {nodequeue_queue} SET name = 'queue'||qid";
+  }
+
+  $ret[] = update_sql($queue_update_sql);
+
+  return $ret;
+
+}
+
 function nodequeue_install() {
   drupal_install_schema('nodequeue');
 }
Index: nodequeue.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodequeue/nodequeue.module,v
retrieving revision 1.107.2.7
diff -u -p -r1.107.2.7 nodequeue.module
--- nodequeue.module	30 Dec 2010 19:29:46 -0000	1.107.2.7
+++ nodequeue.module	30 Dec 2010 21:08:45 -0000
@@ -714,6 +714,21 @@ function nodequeue_edit_queue_form(&$for
     '#description' => t('Enter the name of the queue'),
   );
 
+  $form['name'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Name'),
+    '#size' => 50,
+    '#maxlength' => 32,
+    '#description' => t("This is the unique name of the queue. It must contain only alphanumeric characters and underscores. It is used to identify the queue internally. This name cannot change. The machine name of the subqueue will be automatically generated using the queue's machine name and the subqueue title (if provided). If no title is provided for the subqueue, the subqueue's machine name will be numeric. (e.g. machinename_subqueue1)"),
+    '#required' => TRUE,
+  );
+
+  if (isset($queue->name)) {
+    $form['name']['#default_value'] = $queue->name;
+    $form['name']['#disabled'] = TRUE;
+    $form['name']['#value'] = $queue->name;
+  }
+
   // This is a value; as the default nodequeue implementation has just one
   // queue per nodequeue, this field is totally redundant. Plugins can
   // override this.
@@ -875,6 +890,12 @@ function nodequeue_edit_queue_form(&$for
  * Validate function for the nodequeue_queue form.
  */
 function nodequeue_edit_queue_form_validate($form, &$form_state) {
+  if (preg_match("/[^[:alnum:]_]/", $form_state['values']['name'])) {
+    form_set_error('name', t("The queue's machine name must consist of alphanumeric or underscore characters only."));
+  }
+  if (!nodequeue_machine_name_available($form_state['values']['name'], $form_state['values']['qid'])) {
+    form_set_error('name', t("The queue's machine name is already in use. Please choose a different machine name."));
+  }
   if (empty($form_state['values']['title'])) {
     form_set_error('title', t('Please enter a title for this queue.'));
   }
@@ -925,6 +946,27 @@ function nodequeue_edit_queue_form_submi
 }
 
 /**
+ * Determine if the machine name is in use.
+ */
+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;
+  }
+  else if (count($existing_queues) == 1 && !empty($qid) && $qid == $existing_queues[0]) {
+    // Checking an existing queue that has not changed its name.
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
  * Delete-validate function for the nodequeue_queue form.
  */
 function nodequeue_edit_queue_form_delete_validate($form, &$form_state) {
@@ -1483,6 +1525,38 @@ function nodequeue_load_queues_by_type($
   return nodequeue_load_queues(array_keys($qids), $bypass_cache);
 }
 
+
+/**
+ * Return a queue by its machine name. This is obviously not ideal due to the
+ * extra queries, but probably preferable to changing current API calls.
+ *
+ * @param $name
+ *   The queue's machine name
+ */
+function nodequeue_load_queue_by_name($name) {
+  $map = nodequeue_get_qid_map();
+  return isset($map[$name]) ? nodequeue_load_queues(array($map[$name]) ) : array();
+}
+
+
+/**
+ * Return a map of queue name to qid values to aid in various lookups.
+ *
+ * @return array
+ *   A array of qids, keyed by machine name.
+ */
+function nodequeue_get_qid_map() {
+  static $map = array();
+  if (!$map) {
+    $result = db_query("SELECT qid, name FROM {nodequeue_queue}");
+    while ($get = db_fetch_object($result) ) {
+      $map[$get->name] = $get->qid;
+    }
+  }
+  return $map;
+}
+
+
 /**
  * Used by menu system to determine access to the node and the queue in question.
  *
@@ -1888,14 +1962,20 @@ function nodequeue_load_subqueues_by_ref
  */
 function nodequeue_save(&$queue) {
   if (!isset($queue->qid)) {
-    db_query("INSERT INTO {nodequeue_queue} (title, subqueue_title, size, link, link_remove, owner, show_in_links, show_in_tab, show_in_ui, i18n, reverse, reference) VALUES ('%s', '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s')", $queue->title, $queue->subqueue_title, $queue->size, $queue->link, $queue->link_remove, $queue->owner, $queue->show_in_links, $queue->show_in_tab, $queue->show_in_ui, $queue->i18n, $queue->reverse, $queue->reference);
+    db_query("INSERT INTO {nodequeue_queue} (title, name, subqueue_title, size, link, link_remove, owner, show_in_links, show_in_tab, show_in_ui, i18n, reverse, reference) VALUES ('%s', '%s', '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s')", $queue->title, $queue->name, $queue->subqueue_title, $queue->size, $queue->link, $queue->link_remove, $queue->owner, $queue->show_in_links, $queue->show_in_tab, $queue->show_in_ui, $queue->i18n, $queue->reverse, $queue->reference);
     $queue->qid = db_last_insert_id('nodequeue_queue', 'qid');
     if (function_exists('views_invalidate_cache')) {
       views_invalidate_cache();
     }
   }
   else {
-    db_query("UPDATE {nodequeue_queue} set size = %d, title = '%s', subqueue_title = '%s', link = '%s', link_remove = '%s', owner = '%s', show_in_links = %d, show_in_tab = %d, show_in_ui = %d, i18n = %d, reverse = %d, reference = '%s' WHERE qid = %d", $queue->size, $queue->title, $queue->subqueue_title, $queue->link, $queue->link_remove, $queue->owner, $queue->show_in_links, $queue->show_in_tab, $queue->show_in_ui, $queue->i18n, $queue->reverse, $queue->reference, $queue->qid);
+    // Allow nodequeue to save and not update the name unless supplied
+    if (isset($queue->name) && !empty($queue->name)) {
+      db_query("UPDATE {nodequeue_queue} SET size = %d, title = '%s', subqueue_title = '%s', link = '%s', link_remove = '%s', owner = '%s', show_in_links = %d, show_in_tab = %d, show_in_ui = %d, i18n = %d, reverse = %d, reference = '%s' WHERE qid = %d", $queue->size, $queue->title, $queue->subqueue_title, $queue->link, $queue->link_remove, $queue->owner, $queue->show_in_links, $queue->show_in_tab, $queue->show_in_ui, $queue->i18n, $queue->reverse, $queue->reference, $queue->qid);
+    }
+    else {
+      db_query("UPDATE {nodequeue_queue} SET size = %d, title = '%s', name = '%s', subqueue_title = '%s', link = '%s', link_remove = '%s', owner = '%s', show_in_links = %d, show_in_tab = %d, show_in_ui = %d, i18n = %d, reverse = %d, reference = '%s' WHERE qid = %d", $queue->size, $queue->title, $queue->name, $queue->subqueue_title, $queue->link, $queue->link_remove, $queue->owner, $queue->show_in_links, $queue->show_in_tab, $queue->show_in_ui, $queue->i18n, $queue->reverse, $queue->reference, $queue->qid);
+    }
     db_query("DELETE FROM {nodequeue_roles} WHERE qid = %d", $queue->qid);
     db_query("DELETE FROM {nodequeue_types} WHERE qid = %d", $queue->qid);
   }
@@ -2022,7 +2102,7 @@ function nodequeue_subqueue_add($queue, 
     }
     if (module_exists('apachesolr')) {
       apachesolr_mark_node($nid);
-    }  
+    }
     //Invoke the hook to notify other modules of the node addition.
     module_invoke_all('nodequeue_add', $subqueue->sqid, $nid);
   }
@@ -2073,7 +2153,7 @@ function nodequeue_subqueue_remove($sqid
   $diff = $end - $start + 1;
   db_query("DELETE FROM {nodequeue_nodes} WHERE sqid = %d AND position >= %d AND position <= %d", $sqid, $start, $end);
   db_query("UPDATE {nodequeue_nodes} SET position = position - %d WHERE sqid = %d AND position > %d",  $diff, $sqid, $end);
-  
+
   // Invoke the hook to let other modules know that the nodes were removed.
   while($node = db_fetch_object($result)) {
     module_invoke_all('nodequeue_remove', $sqid, $node->nid);
Index: includes/views/nodequeue.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodequeue/includes/views/nodequeue.views.inc,v
retrieving revision 1.4
diff -u -p -r1.4 nodequeue.views.inc
--- includes/views/nodequeue.views.inc	23 Dec 2008 18:59:55 -0000	1.4
+++ includes/views/nodequeue.views.inc	30 Dec 2010 21:08:45 -0000
@@ -172,6 +172,24 @@ function nodequeue_views_data() {
     ),
   );
 
+  $data['nodequeue_queue']['name'] = array(
+    'title' => t('Queue machine name'),
+    'help' => t('The machine name of the queue.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+
   // ----------------------------------------------------------------
   // nodequeue_subqueue table
   $data['nodequeue_subqueue']['table']['group'] = t('Nodequeue');
Index: includes/views/nodequeue.views_default.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodequeue/includes/views/nodequeue.views_default.inc,v
retrieving revision 1.5
diff -u -p -r1.5 nodequeue.views_default.inc
--- includes/views/nodequeue.views_default.inc	16 Mar 2010 22:07:26 -0000	1.5
+++ includes/views/nodequeue.views_default.inc	30 Dec 2010 21:08:45 -0000
@@ -16,7 +16,7 @@ function nodequeue_views_default_views()
   $queues = nodequeue_load_queues(nodequeue_get_all_qids(NULL));
   foreach ($queues as $queue) {
     $view = new view;
-    $view->name = "nodequeue_$queue->qid";
+    $view->name = "nodequeue_$queue->name";
     $view->description = t("Display a list of all nodes in queue '@queue'", array('@queue' => $queue->title));
     $view->tag = t('nodequeue');
     $view->view_php = '';
@@ -46,7 +46,7 @@ function nodequeue_views_default_views()
           'label' => 'queue',
           'required' => 1,
           'limit' => TRUE,
-          'qids' => array($queue->qid => $queue->qid),
+          'names' => array($queue->name => $queue->name),
           'relationship' => 'none',
         ),
       ),
Index: includes/views/nodequeue_handler_relationship_nodequeue.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodequeue/includes/views/nodequeue_handler_relationship_nodequeue.inc,v
retrieving revision 1.2
diff -u -p -r1.2 nodequeue_handler_relationship_nodequeue.inc
--- includes/views/nodequeue_handler_relationship_nodequeue.inc	31 Jan 2010 23:17:53 -0000	1.2
+++ includes/views/nodequeue_handler_relationship_nodequeue.inc	30 Dec 2010 21:08:45 -0000
@@ -4,11 +4,12 @@
  * Specialized relationship handler to add nodequeues.
  */
 class nodequeue_handler_relationship_nodequeue extends views_handler_relationship {
+
   function option_definition() {
     $options = parent::option_definition();
 
     $options['limit']['default'] = FALSE;
-    $options['qids']['default'] = array();
+    $options['names']['default'] = array();
     return $options;
   }
 
@@ -19,8 +20,6 @@ class nodequeue_handler_relationship_nod
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
 
-    $queues = nodequeue_load_queues(nodequeue_get_all_qids(NULL));
-
     $form['limit'] = array(
       '#type' => 'checkbox',
       '#title' => t('Limit to one or more queues (recommended)'),
@@ -30,16 +29,16 @@ class nodequeue_handler_relationship_nod
     $options = array();
     $queues = nodequeue_load_queues(nodequeue_get_all_qids(NULL));
     foreach ($queues as $queue) {
-      $options[$queue->qid] = $queue->title;
+      $options[$queue->name] = $queue->title;
     }
 
-    $form['qids'] = array(
-      '#prefix' => '<div><div id="edit-options-qids">',
+    $form['names'] = array(
+      '#prefix' => '<div><div id="edit-options-names">',
       '#suffix' => '</div></div>',
       '#type' => 'checkboxes',
       '#title' => t('Queues'),
       '#options' => $options,
-      '#default_value' => $this->options['qids'],
+      '#default_value' => $this->options['names'],
       '#process' => array('expand_checkboxes', 'views_process_dependency'),
       '#dependency' => array('edit-options-limit' => array(TRUE)),
     );
@@ -63,17 +62,22 @@ class nodequeue_handler_relationship_nod
     }
 
     if (!empty($this->options['limit'])) {
+      $qids = array();
+      $map  = nodequeue_get_qid_map();
+      foreach($map as $name => $qid) {
+        if (isset($this->options['names'][$name]) ) {
+          $qids[] = $qid;
+        }
+      }
+
       $join->definition['extra'] = array(array(
         'field' => 'qid',
-        'value' => array_filter($this->options['qids']),
-        'numeric' => TRUE,
+        'value' => $qids,
       ));
     }
 
     $join->construct();
-
     $alias = $join->definition['table'] . '_' . $join->definition['left_table'];
-
     $this->alias = $this->query->add_relationship($alias, $join, 'nodequeue_nodes', $this->relationship);
   }
 }
\ No newline at end of file
