From dc751b70c954daa3d5df5ab228e9eefe5eb6007a Mon Sep 17 00:00:00 2001
From: Mark Dorison <mdorison@gmail.com>
Date: Mon, 15 Aug 2011 16:45:58 -0400
Subject: [PATCH] Back-ported D7 patch to allow for exporting nodes to
 features on a content type by content type basis. Sites
 with large numbers of nodes would exhaust their memory on
 the features creation page without this ability to limit to
 specific content types.

---
 includes/uuid_node.features.inc |   10 +++++++++-
 uuid_features.module            |   18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/includes/uuid_node.features.inc b/includes/uuid_node.features.inc
index 3275bbf..0861e75 100644
--- a/includes/uuid_node.features.inc
+++ b/includes/uuid_node.features.inc
@@ -10,12 +10,20 @@
 function uuid_node_features_export_options() {
   $options = array();
 
+  // Get the content type names, as well as which to be available for Features.
   $types = node_get_types('names');
 
+  $available = array_filter(variable_get('uuid_features_uuid_node_contenttypes', array()));
+  // Query all the content of the given types
   $query = 'SELECT n.nid, n.title, n.type, u.uuid
     FROM {node} n INNER JOIN {uuid_node} u 
-    ON n.nid = u.nid ORDER BY n.type, n.title ASC';
+    ON n.nid = u.nid';
+  if (!empty($available)) {
+    $query .= ' WHERE n.type IN ("' . implode('","', $available) . '")';
+  }
+  $query .= ' ORDER BY n.type, n.title ASC';
   $result = db_query($query);
+
   while ($node = db_fetch_object($result)) {
     $options[$node->uuid] = t('@type: @title', array(
       '@type' => $types[$node->type], 
diff --git a/uuid_features.module b/uuid_features.module
index c6d7f91..b7bc488 100644
--- a/uuid_features.module
+++ b/uuid_features.module
@@ -135,3 +135,21 @@ if (!function_exists('uuid_set_uuid')) {
     return $uuid;
   }
 }
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ *
+ * Provide Features configuration options to the UUID settings form.
+ */
+function uuid_features_form_alter(&$form, $form_state, $form_id) {
+  // Add options for the UUID Node module.
+  if (module_exists('uuid') && $form_id == 'uuid_admin') {
+    $form['settings']['uuid_features_uuid_node_contenttypes'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Features content type support'),
+      '#description' => t('Select which content types will be available for Features support. If none are selected, all content types will be displayed.'),
+      '#options' => node_get_types('names'),
+      '#default_value' => variable_get('uuid_features_uuid_node_contenttypes', array()),
+    );
+  }
+}
-- 
1.7.4.4

