? 913474_nodequeue_edit_link_permission.patch
? fix_hook_nodequeue_remove.patch
? nodequeue-286918-return.patch
? nodequeue-machine-names-7.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_machine_names-7.patch
? nodequeue_uninitialized_in_db_query.patch
? nodequeue_views.patch.txt
? nodequeue_views.patch.txt.1
? includes/views/nodequeue_handler_relationship_nodequeue-orig.inc
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 22:40:09 -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 22:40:10 -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."),
+    '#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 22:40:10 -0000
@@ -45,6 +45,9 @@ function nodequeue_views_handlers() {
       'nodequeue_handler_relationship_nodequeue' => array(
         'parent' => 'views_handler_relationship',
       ),
+      'nodequeue_handler_relationship_nodequeue_queue_name' => array(
+        'parent' => 'views_handler_relationship',
+      ),
     ),
   );
 }
@@ -172,6 +175,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');
@@ -230,8 +251,8 @@ function nodequeue_views_data_alter(&$da
   // queue relationship
   $data['node']['nodequeue_rel'] = array(
     'group' => t('Nodequeue'),
-    'title' => t('Queue'),
-    'help' => t('Create a relationship to a nodequeue.'),
+    'title' => t('Queue (qid)'),
+    'help' => t('Create a relationship to a nodequeue. This relationship requires one less JOIN than the queue name relationship, but is less useful if you are exporting this view across sites.'),
     'real field' => 'nid',
     'relationship' => array(
       'handler' => 'nodequeue_handler_relationship_nodequeue',
@@ -241,6 +262,19 @@ function nodequeue_views_data_alter(&$da
     ),
   );
 
+  $data['node']['nodequeue_rel_queue_name'] = array(
+    'group' => t('Nodequeue'),
+    'title' => t('Queue (name)'),
+    'help' => t('Create a relationship to a nodequeue. This relationship requires an additional JOIN versus the queue qid based relationship, but is more useful for exporting views across sites.'),
+    'real field' => 'nid',
+    'relationship' => array(
+      'handler' => 'nodequeue_handler_relationship_nodequeue_queue_name',
+      'base' => 'nodequeue_nodes',
+      'field' => 'nid',
+      'label' => t('queue'),
+    ),
+  );
+
   // links
   $data['node']['nodequeue_links'] = array(
     '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 22:40:10 -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 = '';
Index: includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc
===================================================================
RCS file: includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc
diff -N includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/views/nodequeue_handler_relationship_nodequeue_queue_name.inc	30 Dec 2010 22:40:10 -0000
@@ -0,0 +1,83 @@
+<?php
+//$Id: nodequeue_handler_relationship_nodequeue.inc,v 1.2 2010/01/31 23:17:53 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);
+
+    $form['limit'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Limit to one or more queues (recommended)'),
+      '#default_value'=> $this->options['limit'],
+    );
+
+    $options = array();
+    $queues = nodequeue_load_queues(nodequeue_get_all_qids(NULL));
+    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'],
+      '#process' => array('expand_checkboxes', 'views_process_dependency'),
+      '#dependency' => array('edit-options-limit' => array(TRUE)),
+    );
+  }
+
+  /**
+   * 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' => $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
