Binary files /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/.DS_Store and ./.DS_Store differ
diff -urPp /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/includes/views/nodequeue.views.inc ./includes/views/nodequeue.views.inc
--- /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/includes/views/nodequeue.views.inc	2010-12-24 21:55:09.000000000 +0100
+++ ./includes/views/nodequeue.views.inc	2011-01-25 13:59:55.000000000 +0100
@@ -109,6 +109,26 @@ function nodequeue_views_data() {
       'label' => t('In queue'),
     ),
   );
+  
+  $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_queue table
@@ -198,11 +218,11 @@ function nodequeue_views_data_alter(&$da
   // queue relationship
   $data['node']['nodequeue_rel'] = array(
     'group' => t('Nodequeue'),
-    'title' => t('Queue'),
+    'title' => t('Queue (name)'),
     'help' => t('Create a relationship to a nodequeue.'),
     'real field' => 'nid',
     'relationship' => array(
-      'handler' => 'nodequeue_handler_relationship_nodequeue',
+      'handler' => 'nodequeue_handler_relationship_nodequeue_queue_name',
       'base' => 'nodequeue_nodes',
       'field' => 'nid',
       'label' => t('queue'),
Only in /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/includes/views: nodequeue_handler_relationship_nodequeue.inc
diff -urPp /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc ./includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc
--- /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc	1970-01-01 01:00:00.000000000 +0100
+++ ./includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc	2011-01-25 14:04:30.000000000 +0100
@@ -0,0 +1,91 @@
+<?php
+//$Id: nodequeue_handler_relationship_nodequeue.inc,v 1.4 2010/12/24 20:55:09 ezrag Exp $
+/**
+ * Specialized relationship handler to add nodequeues.
+ */
+class nodequeue_handler_relationship_nodequeue_queue_name extends views_handler_relationship {
+  function option_definition() {
+    $options = parent::option_definition();
+
+    $options['limit']['default'] = FALSE;
+    $options['names']['default'] = array();
+    return $options;
+  }
+
+  /**
+   * Default options form that provides the label widget that all fields
+   * should have.
+   */
+  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)'),
+      '#default_value' => $this->options['limit'],
+    );
+
+    $options = array();
+
+    foreach ($queues as $queue) {
+      $options[$queue->name] = $queue->title;
+    }
+
+    $form['names'] = array(
+      '#prefix' => '<div><div id="edit-options-names">',
+      '#suffix' => '</div></div>',
+      '#type' => 'checkboxes',
+      '#title' => t('Queues'),
+      '#options' => $options,
+      '#default_value' => $this->options['names'],
+      '#states' => array(
+        'visible' => array(
+          ':input[name="options[limit]"]' => array('checked' => TRUE)
+        ),      
+      ),
+      //'#process' => array('expand_checkboxes', 'views_process_dependency'), //from D6 version
+      //'#dependency' => array('edit-options-limit' => array(TRUE)),  //from D6 version
+    );
+  }
+
+  /**
+   * Called to implement a relationship in a query.
+   */
+  function query() {
+    // Figure out what base table this relationship brings to the party.
+    $join = new views_join();
+    $join->definition = array(
+      'table' => 'nodequeue_nodes',
+      'field' => 'nid',
+      'left_table' => 'node',
+      'left_field' => 'nid',
+    );
+
+    if (!empty($this->options['required'])) {
+      $join->definition['type'] = 'INNER';
+    }
+
+    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' => $quids,
+      ));
+    }
+
+    $join->construct();
+
+    $alias = $join->definition['table'] . '_' . $join->definition['left_table'];
+
+    $this->alias = $this->query->add_relationship($alias, $join, 'nodequeue_nodes', $this->relationship);
+  }
+}
diff -urPp /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/nodequeue.info ./nodequeue.info
--- /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/nodequeue.info	2011-01-05 07:21:05.000000000 +0100
+++ ./nodequeue.info	2011-01-25 14:03:04.000000000 +0100
@@ -16,7 +16,7 @@ files[] = includes/views/nodequeue_handl
 files[] = includes/views/nodequeue_handler_field_links.inc
 files[] = includes/views/nodequeue_handler_field_queue_tab.inc
 files[] = includes/views/nodequeue_handler_filter_in_queue.inc
-files[] = includes/views/nodequeue_handler_relationship_nodequeue.inc
+files[] = includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc
 
 ; Information added by drupal.org packaging script on 2011-01-05
 version = "7.x-2.0-alpha1"
diff -urPp /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/nodequeue.install ./nodequeue.install
--- /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/nodequeue.install	2010-10-07 04:50:35.000000000 +0200
+++ ./nodequeue.install	2011-01-25 13:37:25.000000000 +0100
@@ -17,6 +17,11 @@ function nodequeue_schema() {
         'unsigned' => TRUE,
         'not null' => TRUE
       ),
+      'name' => array(
+        'description' => 'The machine name for the queue.',
+        'type' => 'varchar',
+        'length' => 128,
+      ),
       'title' => array(
         'description' => 'Title of a queue.',
         'type' => 'varchar',
@@ -86,6 +91,9 @@ function nodequeue_schema() {
       ),
     ), // fields
     'primary key' => array('qid'),
+    'unique keys' => array(
+      'name' => array('name')
+    ),
   ); // nodequeue_queue.
   $schema['nodequeue_roles'] = array(
     'description' => 'Defines the roles which are allowed to use a particular nodequeue.',
@@ -446,6 +454,21 @@ function nodequeue_update_6005() {
   $ret[] = update_sql("UPDATE {system} set name = 'nodequeue_view_per_queue' where name = 'nodequeue_automatic_views_generation'");
   return $ret;
 }
+
+/*
+ * Provide machine names, and auto-generation of machine names for existing
+ * queues.
+ */
+function nodequeue_update_7000() {
+  db_add_field('nodequeue_queue', 'name', array('type' => 'varchar', 'length' => 128));
+  db_add_unique_key('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}"
+  db_query("UPDATE {nodequeue_queue} SET name = CONCAT('queue', qid)");    
+}
+
 /**
  * Implements hook_requirements().
  *
diff -urPp /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/nodequeue.module ./nodequeue.module
--- /Users/robert/Sites/cesca/sites/all/modules/contrib/nodequeue/nodequeue.module	2011-01-05 07:13:22.000000000 +0100
+++ ./nodequeue.module	2011-01-25 20:48:59.000000000 +0100
@@ -736,6 +736,20 @@ function nodequeue_edit_queue_form($form
     '#maxlength' => 64,
     '#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."),
+    '#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
@@ -898,6 +912,12 @@ function nodequeue_edit_queue_form($form
  * 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.'));
   }
@@ -948,6 +968,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 ':name'", array(':name', $machine_name));
+  $existing_queues = array();
+  foreach ($result as $record) {
+    $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) {
@@ -1535,6 +1576,48 @@ function nodequeue_load_queues_by_type($
 }
 
 /**
+ * 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 machine name
+ *
+ * @return
+ *   The queue definition, or an empty array if no queue was found with the
+ *   given machine name.
+ */
+function nodequeue_load_queue_by_name($name) {
+  $map = nodequeue_get_qid_map();
+  if (isset($map[$name])) {
+    $queues = nodequeue_load_queues(array($map[$name]));
+    if ($queues) {
+      return current($queues);
+    }
+  }
+
+  return 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.
  *
  * No, this isn't some odd hook_access implementation.
@@ -1920,6 +2003,7 @@ function nodequeue_load_subqueues_by_ref
  */
 function nodequeue_save(&$queue) {
   $nodequeue_queue_fields = array(
+    'name' => $queue->name,
     'title' => $queue->title,
     'subqueue_title' => $queue->subqueue_title,
     'size' => $queue->size,
