Index: nodehierarchy.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy.install,v
retrieving revision 1.4.2.2
diff -u -p -r1.4.2.2 nodehierarchy.install
--- nodehierarchy.install	26 Sep 2010 04:03:15 -0000	1.4.2.2
+++ nodehierarchy.install	10 Nov 2010 18:35:08 -0000
@@ -137,11 +137,58 @@ function nodehierarchy_update_6200() {
   return $out;
 }
 
+/**
+ * Convert valid variables and clean up unused variables for use with 6.x-2.x schema
+ */
+function nodehierarchy_update_6201() {
+  $ret = array();
+  $renamed = array();
+  $remove = array();
+  $types = array_keys(node_get_types());
+  $query = db_query('SELECT * FROM {variable} WHERE name LIKE \'nh_%\'');
+  while ($row = db_fetch_object($query)) {
+    // Rename accepted variables
+    $pattern = array(
+      // Children
+      '^nh_allowchild_(.*)$'            => 'nh_children_allowed_types_',
+      // Parents
+      '^nh_defaultparent_(.*)$'         => 'nh_parent_node_',
+      '^nh_multiple_(.*)$'              => 'nh_parent_multiple_',
+      // Menus
+      '^nh_createmenu_(.*)$'            => 'nh_menu_create_',
+      //Views
+      '^nh_default_children_view_(.*)$' => 'nh_view_default_',
+    );
+    foreach($pattern as $variable => $replace) {
+      $match = array();
+      $regex = '/' . $variable . '/i';
+      if (preg_match($regex, $row->name, $match)) {
+        // Add the matched patterns so they are removed
+        $remove[] = $row->name;
+        // Rename only valid node types and remove the node types that no longer exist.
+        // After this update, Node Hierarchy settings for the respected node type are deleted when the node type is deleted or this module is uninstalled.
+        if (in_array($match[1], $types)) {
+          $renamed[$replace . $match[1]] = $row->value;
+        }
+        break;
+      }
+    }
+  }
+  foreach($renamed as $name => $value) {
+    if (!db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $value)) {
+      $ret[] = array('success' => FALSE, 'query' => check_plain('Could not rename Node Hierarchy variables.'));  
+      return $ret;
+    }
+  }
+  if (!empty($remove)) {
+    db_query('DELETE FROM {variable} WHERE name IN (' . db_placeholders($remove, 'varchar') . ')', $remove);
+  }
+  $ret[] = array('success' => TRUE, 'query' => check_plain(count($renamed) . ' Node Hierarchy variables renamed.'));  
+  return $ret; 
+}
+
 function nodehierarchy_uninstall() {
   drupal_uninstall_schema('nodehierarchy');
-  foreach (node_get_types() as $key => $type) {
-    variable_del('nh_allowchild_'. $key);
-    variable_del('nh_parent_'. $key);
-    variable_del('nh_defaultparent_'. $key);
-  }
+  // Run a LIKE query to delete all variables that start with 'nh_', this way we don't have to update this function in the future
+  db_query("DELETE FROM {variable} WHERE name LIKE 'nh_%'");
 }
Index: nodehierarchy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy.module,v
retrieving revision 1.12.2.22
diff -u -p -r1.12.2.22 nodehierarchy.module
--- nodehierarchy.module	26 Sep 2010 04:03:16 -0000	1.12.2.22
+++ nodehierarchy.module	10 Nov 2010 18:35:08 -0000
@@ -163,7 +163,7 @@ function nodehierarchy_admin_settings() 
       '#collapsible' => TRUE,
       '#collapsed' => TRUE,
     );
-    $form['nodehierarchy_types'][$key] += _nodehierarchy_get_node_type_settings_form($key, TRUE);
+    $form['nodehierarchy_types'][$key] += _nodehierarchy_get_node_type_settings_form($key);
   }
 
   // Menu generation.
@@ -467,7 +467,7 @@ function nodehierarchy_nodehierarchy_nod
       drupal_add_js(drupal_get_path("module", "nodehierarchy") .'/nodehierarchy.js');
 
       $form['nodehierarchy_menu_links'] = array('#tree' => TRUE);
-      $multiple = variable_get('nh_multiple_'. $node->type, 0);
+      $multiple = variable_get('nh_parent_multiple_'. $node->type, 0);
 
       $count = 2;
 
@@ -538,7 +538,7 @@ function _nodehierarchy_node_parent_form
     '#type' => 'value',
     '#value' => $menu_link['mlid'],
   );
-  $create_menu = variable_get('nh_createmenu_'. $node->type, 'optional_no');
+  $create_menu = variable_get('nh_menu_create_'. $node->type, 'optional_no');
   // Prevent menus from being created for non-primary parents. That prevernts weirdness
   // caused by Drupal 6 core's inconsisnency of defining the active menu trail when there
   // menu items pointing to the same node.
@@ -730,7 +730,7 @@ function nodehierarchy_nodehierarchy_def
   if (nodehierarchy_node_can_be_child($node) || nodehierarchy_node_can_be_parent($node)) {
     if (!isset($node->nodehierarchy_menu_links) || empty($node->nodehierarchy_menu_links)) {
       // Should this menu item be enabled or not.
-      $create_menu = variable_get('nh_createmenu_'. $node->type, 'optional_no');
+      $create_menu = variable_get('nh_menu_create_'. $node->type, 'optional_no');
       $enabled = ($create_menu == 'optional_yes' || $create_menu == 'always');
 
       // Create a default menu_link object.
@@ -738,7 +738,7 @@ function nodehierarchy_nodehierarchy_def
 
       // Set the type default if there is one.
       if (empty($node->nid)) {
-        $default = variable_get('nh_defaultparent_'. $node->type, 0);
+        $default = variable_get('nh_parent_node_'. $node->type, 0);
         // Get the parent node id from passed in from the get params.
         $pnid = !empty($_GET['parent']) ? (int)$_GET['parent'] : $default;
         // Get the parent from the get string. User must have update perms for parent unless it is the default.
@@ -786,22 +786,22 @@ function nodehierarchy_delete_descendant
 /**
  * Get the nodehierarchy setting form for a particular node type.
  */
-function _nodehierarchy_get_node_type_settings_form($key, $append_key = FALSE) {
-  $form              = array();
-  $form['nh_allowchild'] = array(
+function _nodehierarchy_get_node_type_settings_form($type) {
+  $form = array();
+  $form['nh_children_allowed_types_' . $type] = array(
     '#type' => 'checkboxes',
     '#title' => t('Allowed child node types'),
     '#options' => node_get_types('names'),
-    '#default_value' => nodehierarchy_get_allowed_child_types($key),
+    '#default_value' => nodehierarchy_get_allowed_child_types($type),
     '#description' => t('Node types which can be created as child nodes of this node type.'),
   );
-  $form['nh_defaultparent'] = _nodehierarchy_get_parent_selector($key, variable_get('nh_defaultparent_'. $key, 0));
-  $form['nh_defaultparent']['#title'] = t('Default Parent');
+  $form['nh_parent_node_' . $type] = _nodehierarchy_get_parent_selector($type, variable_get('nh_parent_node_'. $type, 0));
+  $form['nh_parent_node_' . $type]['#title'] = t('Default Parent');
 
-  $form['nh_createmenu'] = array(
+  $form['nh_menu_create_' . $type] = array(
     '#type' => 'radios',
     '#title' => t('Show item in menu'),
-    '#default_value' => variable_get('nh_createmenu_'. $key, 'optional_no'),
+    '#default_value' => variable_get('nh_menu_create_'. $type, 'optional_no'),
     '#options' => array(
       'never' => t('Never'),
       'optional_no' => t('Optional - default to no'),
@@ -810,23 +810,15 @@ function _nodehierarchy_get_node_type_se
     ),
     '#description' => t("Users must have the 'administer menu' or 'customize nodehierarchy menus' permission to override default options."),
   );
-  $form['nh_multiple'] = array(
+  $form['nh_parent_multiple_' . $type] = array(
     '#type' => 'checkbox',
     '#title' => t('Allow multiple parents'),
-    '#default_value' => variable_get('nh_multiple_'. $key, 0),
+    '#default_value' => variable_get('nh_parent_multiple_'. $type, 0),
     '#description' => t('Can nodes of this type have multiple parents?.'),
   );
-
-  $form += module_invoke_all('nodehierarchy_node_type_settings_form', $key);
-
-  // If we need to append the node type key to the form elements, we do so.
-  if ($append_key) {
-    // Appending the key does not work recursively, so fieldsets etc. are not supported.
-    foreach (element_children($form) as $form_key) {
-      $form[$form_key .'_'. $key] = $form[$form_key];
-      unset($form[$form_key]);
-    }
-  }
+  
+  // Merge settings from modules that implement 'nodehierarchy_node_type_settings_form' hook
+  $form = array_merge_recursive($form, module_invoke_all('nodehierarchy_node_type_settings_form', $type));
   return $form;
 }
 
@@ -866,7 +858,7 @@ function nodehierarchy_node_can_be_child
 function nodehierarchy_get_allowed_parent_types($child_type = NULL) {
   $parent_types = array();
   foreach (node_get_types() as $type => $info) {
-    $allowed_children = array_filter(variable_get('nh_allowchild_'. $type, array()));
+    $allowed_children = array_filter(variable_get('nh_children_allowed_types_'. $type, array()));
     if ((empty($child_type) && !empty($allowed_children)) || (in_array($child_type, (array)$allowed_children, TRUE))) {
       $parent_types[] = $type;
     }
@@ -878,7 +870,7 @@ function nodehierarchy_get_allowed_paren
  * Get the allwed parent types for the given child type.
  */
 function nodehierarchy_get_allowed_child_types($parent_type) {
-  $child_types = array_filter(variable_get('nh_allowchild_'. $parent_type, array()));
+  $child_types = array_filter(variable_get('nh_children_allowed_types_'. $parent_type, array()));
   return array_unique($child_types);
 }
 
@@ -911,7 +903,7 @@ function nodehierarchy_children_form(&$f
       $child_item['type']       = array('#value' => $type_names[$child->type]);
       $child_item['weight']     = array(
         '#type' => 'weight',
-        '#delta' => 50,
+        '#delta' => count($child_links),
         '#default_value' => isset($form_state[$child_link['mlid']]['weight']) ? $form_state[$child_link['mlid']]['weight'] : $child_link['weight'],
       );
 
@@ -1559,6 +1551,11 @@ function _nodehierarchy_tree_data($resul
   $exclude = NULL;
 
   while ($item = db_fetch_array($result)) {
+    // Only show items that are assigned to the site's default menu. This is is predominately for Domain Access support.
+    // By design, a singular site employs this natively given Node Hierarchy uses only one parent menu per site.
+    if ($item['menu_name'] != variable_get('nodehierarchy_default_menu_name', 'navigation')) {
+      continue;
+    }
     if ($exclude !== $item['nid']) {
       $item['format'] = FILTER_FORMAT_DEFAULT;
       $item['disabled'] = in_array($item['type'], $allowed_types) ? FALSE : TRUE;
Index: nodehierarchy_views/nodehierarchy_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodehierarchy/nodehierarchy_views/nodehierarchy_views.module,v
retrieving revision 1.8.2.4
diff -u -p -r1.8.2.4 nodehierarchy_views.module
--- nodehierarchy_views/nodehierarchy_views.module	27 Aug 2010 22:35:24 -0000	1.8.2.4
+++ nodehierarchy_views/nodehierarchy_views.module	10 Nov 2010 18:35:08 -0000
@@ -102,13 +102,13 @@ function nodehierarchy_views_nodehierarc
 function nodehierarchy_views_nodehierarchy_node_type_settings_form($type) {
   $form = array();
   if (nodehierarchy_node_can_be_parent($type)) {
-    $form['nh_default_children_view'] = array(
+    $form['nh_view_default_' . $type] = array(
       '#type'           => 'select',
       '#title'          => t('Default Children View'),
       '#multiple'       => FALSE,
       '#options'        => _nodehierarchy_views_view_options(),
       '#required'       => FALSE,
-      '#default_value'  => variable_get('nh_default_children_view_'. $type, NULL),
+      '#default_value'  => variable_get('nh_view_default_'. $type, NULL),
       '#description'    => t('Default for the embed children view feature.'),
     );
   }
@@ -128,7 +128,7 @@ function nodehierarchy_views_load_node($
  */
 function nodehierarchy_views_prepare_node(&$node) {
   // Set the default children view if there is one for this type and if the node has not been saved yet.
-  if (empty($node->nid) && !$node->nh_children_view && $children_view = variable_get('nh_default_children_view_'. $node->type, NULL)) {
+  if (empty($node->nid) && !$node->nh_children_view && $children_view = variable_get('nh_view_default_'. $node->type, NULL)) {
     list($node->nh_children_view, $node->nh_children_display) = explode(':', $children_view);
   }
 }
@@ -162,7 +162,7 @@ function nodehierarchy_views_insert($nod
     nodehierarchy_views_update($node);
   }
   // Otherwise set it to the default.
-  elseif ($children_view = variable_get('nh_default_children_view_'. $node->type, NULL)) {
+  elseif ($children_view = variable_get('nh_view_default_'. $node->type, NULL)) {
     list($view, $display) = explode(':', $children_view);
     db_query("INSERT INTO {nodehierarchy_views} (nid, nh_children_view) VALUES (%d, '%s')", $node->nid, $view, $display);
   }
