Index: hierarchical_select.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/hierarchical_select.module,v
retrieving revision 1.176
diff -u -F '^f' -r1.176 hierarchical_select.module
--- hierarchical_select.module	18 Oct 2009 14:25:38 -0000	1.176
+++ hierarchical_select.module	30 Oct 2009 18:31:41 -0000
@@ -100,6 +100,7 @@ function hierarchical_select_elements() 
       'save_lineage'    => 0,
       'enforce_deepest' => 0,
       'entity_count'    => 0,
+      'require_entity'  => 0,
       'resizable'       => 1,
       'level_labels' => array(
         'status' => 0,
@@ -476,7 +477,7 @@ function hierarchical_select_process($el
   // - at least one special item has the 'exclusive' property
   // - the dropbox is enabled
   // then do the necessary processing to make exclusive lineages possible.
-  if (isset($config['special_items']) && count($special_items['exclusive']) && $config['dropbox']['status']) {
+  if (isset($special_item) && count($special_items['exclusive']) && $config['dropbox']['status']) {
     // When the form is first loaded, $db_selection will contain the selection
     // that we should check, but in updates, $hs_selection will.
     $selection = (!empty($hs_selection)) ? $hs_selection : $db_selection;
@@ -535,7 +536,7 @@ function hierarchical_select_process($el
 
   // The selects in the hierarchical select should inherit the #size property.
   foreach (element_children($element['hierarchical_select']['selects']) as $depth) {
-    $element['hierarchical_select']['selects'][$depth]['#size'] = $element['#size'];
+    $element['hierarchical_select']['selects'][$depth]['#size'] = isset($element['#size']) ? $element['#size'] : 0;
   }
 
   // Check if a new item is being created.
@@ -654,7 +655,9 @@ function hierarchical_select_process($el
   // is set to 'label_0' after an "Add" operation. When $element['#post'] is
   // NOT unset, the corresponding value in $element['#post'] will be used
   // instead of the default value that was set. This is undesired behavior.
-  unset($element['#post']);
+  if (isset($element['#post'])) {
+    unset($element['#post']);
+  }
 
   // Finally, calculate the return value of this hierarchical_select form
   // element. This will be set in _hierarchical_select_validate(). (If we'd
@@ -682,7 +685,7 @@ function hierarchical_select_process($el
 
   // If the form item is marked as disabled, disable all child form items as
   // well.
-  if ($element['#disabled']) {
+  if (isset($element['#disabled']) && $element['#disabled']) {
     _hierarchical_select_mark_as_disabled($element);
   }
 
@@ -746,7 +749,7 @@ function hierarchical_select_after_build
   // the associated values from the cache. The _hierarchical_select_submit()
   // must be the first submit callback to ensure that it's executed: if a
   // submit callback before it performs a drupal_goto(), it won't be called!
-  $form_state['hs_form_build_id'] = $_POST['hs_form_build_id'];
+  $form_state['hs_form_build_id'] = $hs_form_build_id;
   $form['#submit'] = (is_array($form['#submit'])) ? $form['#submit'] : array();
   $form['#submit'] = array_merge(array('_hierarchical_select_submit'), $form['#submit']);
 
@@ -796,7 +799,7 @@ function _hierarchical_select_validate(&
   // If the form item is disabled, set the default value as the return value,
   // because otherwise nothing would be returned (disabled form items are not
   // submitted, as described in the HTML standard).
-  if ($element['#disabled']) {
+  if (isset($element['#disabled']) && $element['#disabled']) {
     $element['#return_value'] = $element['#default_value'];
   }
 
@@ -849,7 +852,7 @@ function _hierarchical_select_process_ge
   $hs_selection = array();
   $config = _hierarchical_select_inherit_default_config($element['#config']);
 
-  if (count($element['#value']['hierarchical_select']['selects'])) {
+  if (!empty($element['#value']['hierarchical_select']['selects'])) {
     if ($config['save_lineage']) {
       foreach ($element['#value']['hierarchical_select']['selects'] as $key => $value) {
         $hs_selection[] = $value;
@@ -889,7 +892,7 @@ function _hierarchical_select_process_ge
 function _hierarchical_select_process_get_db_selection($element) {
   $db_selection = array();
 
-  if (count($element['#value']['dropbox']['hidden']['lineages_selections'])) {
+  if (!empty($element['#value']['dropbox']['hidden']['lineages_selections'])) {
     // This is only present in #value if at least one "Remove" checkbox was
     // checked, so ensure that we're doing something valid.
     $remove_from_db_selection = (!isset($element['#value']['dropbox']['visible']['lineages'])) ? array() : array_keys($element['#value']['dropbox']['visible']['lineages']);
@@ -951,14 +954,13 @@ function _hierarchical_select_process_ca
 
   $config = _hierarchical_select_inherit_default_config($element['#config']);
   $dropbox = (bool) $config['dropbox']['status'];
-  $op = $element['#post']['op'];
 
   // When:
-  // - no data was POSTed,
+  // - no data was POSTed (and thus no 'op', no operation),
   // - or #value is set directly and not by a Hierarchical Select POST (and
   //   therefor set either manually or by another module),
   // then use the value of #default_value, or when available, of #value.
-  if (empty($element['#post']) || !isset($element['#value']['hierarchical_select'])) {
+  if (!isset($element['#post']['op']) || !isset($element['#value']['hierarchical_select'])) {
     $value = (isset($element['#value'])) ? $element['#value'] : $element['#default_value'];
     $value = (is_array($value)) ? $value : array($value);
     if ($dropbox) {
@@ -969,6 +971,7 @@ function _hierarchical_select_process_ca
     }
   }
   else {
+    $op = $element['#post']['op'];
     if ($dropbox && $op == t('Add')) {
       $hs_selection = _hierarchical_select_process_get_hs_selection($element);
       $db_selection = _hierarchical_select_process_get_db_selection($element);
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/includes/common.inc,v
retrieving revision 1.28
diff -u -F '^f' -r1.28 common.inc
--- includes/common.inc	24 Sep 2009 12:41:22 -0000	1.28
+++ includes/common.inc	30 Oct 2009 18:31:41 -0000
@@ -56,7 +56,7 @@ function hierarchical_select_common_conf
  */
 function hierarchical_select_common_config_apply(&$form_item, $config_id, $defaults_override = array()) {
   $config = hierarchical_select_common_config_get($config_id, $defaults_override);
-  $form_item['#config'] = array_merge((is_array($form_item['#config'])) ? $form_item['#config'] : array(), $config);
+  $form_item['#config'] = array_merge((isset($form_item['#config']) && is_array($form_item['#config'])) ? $form_item['#config'] : array(), $config);
 }
 
 
@@ -226,7 +226,7 @@ function hierarchical_select_common_conf
       '#type' => 'textfield',
       '#size' => 20,
       '#maxlength' => 255,
-      '#default_value' => $config['level_labels']['labels'][$depth],
+      '#default_value' => (isset($config['level_labels']['labels'][$depth])) ? $config['level_labels']['labels'][$depth] : NULL,
       '#attributes' => array('class' => 'level-label'),
     );
   }
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/includes/theme.inc,v
retrieving revision 1.9
diff -u -F '^f' -r1.9 theme.inc
--- includes/theme.inc	30 Oct 2009 16:20:58 -0000	1.9
+++ includes/theme.inc	30 Oct 2009 18:31:41 -0000
@@ -24,6 +24,9 @@ function theme_hierarchical_select($elem
   $output = '';
 
   // Update $element['#attributes']['class'].
+  if (!isset($element['#attributes']['class'])) {
+    $element['#attributes']['class'] = '';
+  }
   $hsid = $element['hsid']['#value'];
   $level_labels_style = variable_get('hierarchical_select_level_labels_style', 'none');
   $classes = array(
@@ -46,7 +49,7 @@ function theme_hierarchical_select($elem
       '#description' => $element['#description'],
       '#id' => $element['#id'],
       '#required' => $element['#required'],
-      '#error' => $element['#error'],
+      '#error' => isset($element['#error']) ? $element['#error'] : '',
     ),
     '<div '. drupal_attributes($element['#attributes']) .'>'. $element['#children'] .'</div>'
   );
Index: modules/hs_menu.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/modules/hs_menu.module,v
retrieving revision 1.13
diff -u -F '^f' -r1.13 hs_menu.module
--- modules/hs_menu.module	5 Aug 2009 08:17:44 -0000	1.13
+++ modules/hs_menu.module	30 Oct 2009 18:31:41 -0000
@@ -29,7 +29,7 @@ function hs_menu_menu() {
  * Implementation of hook_form_alter().
  */
 function hs_menu_form_alter(&$form, &$form_state, $form_id) {
-  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['menu']['parent']) && $form['menu']['#access']) {
+  if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['menu']['parent']) && $form['menu']['#access']) {
     unset($form['menu']['parent']['#options']);
     $form['menu']['parent']['#type'] = 'hierarchical_select';
     _hs_menu_apply_config($form['menu']['parent'], NULL);
Index: modules/hs_taxonomy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/modules/hs_taxonomy.module,v
retrieving revision 1.35
diff -u -F '^f' -r1.35 hs_taxonomy.module
--- modules/hs_taxonomy.module	29 Sep 2009 14:13:46 -0000	1.35
+++ modules/hs_taxonomy.module	30 Oct 2009 18:31:42 -0000
@@ -135,14 +135,14 @@ function hs_taxonomy_form_taxonomy_form_
       'status'   => 1,
     ),
     'params' => array(
-      'vid'         => $form['vid']['#value'],
-      'exclude_tid' => $form['tid']['#value'],
+      'vid'         => isset($form['tid']['#value']) ? $form['vid']['#value'] : NULL,
+      'exclude_tid' => isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL,
       'root_term'   => TRUE,
     ),
   );
 
   // Use Hierarchical Select for selecting the parent term(s).
-  $parent = array_keys(taxonomy_get_parents($form['tid']['#value']));
+  $parent = isset($form['tid']['#value']) ? array_keys(taxonomy_get_parents($form['tid']['#value'])) : array();
   $form['advanced']['parent'] = array(
     '#type'   => 'hierarchical_select',
     '#config' => $config,
@@ -155,7 +155,7 @@ function hs_taxonomy_form_taxonomy_form_
   $form['advanced']['parent']['#config']['dropbox']['title'] = t('All parent terms');
 
   // Use Hierarchical Select for selecting the related term(s).
-  $related = array_keys(taxonomy_get_related($form['tid']['#value']));
+  $related = isset($form['tid']['#value']) ? array_keys(taxonomy_get_related($form['tid']['#value'])) : array();
   $form['advanced']['relations'] = array(
     '#type'   => 'hierarchical_select',
     '#config' => $config,
@@ -215,7 +215,6 @@ function hs_taxonomy_form($vid, $value =
     ),
     '#title'         => $title,
     '#default_value' => $value,
-    '#options'       => $options,
     '#description'   => $description,
     '#weight'        => -15,
   );
@@ -327,7 +326,7 @@ function hs_taxonomy_hierarchical_select
   $terms = _hs_taxonomy_hierarchical_select_get_tree($params['vid'], 0, -1, 1);
 
   // If the root_term parameter is enabled, then prepend a fake "<root>" term.
-  if ($params['root_term'] === TRUE) {
+  if (isset($params['root_term']) && $params['root_term'] === TRUE) {
     $root_term = new StdClass();
     $root_term->tid = 0;
     $root_term->name = '<'. t('root') .'>';
@@ -350,7 +349,7 @@ function hs_taxonomy_hierarchical_select
  * Implementation of hook_hierarchical_select_children().
  */
 function hs_taxonomy_hierarchical_select_children($parent, $params) {
-  if ($params['root_term'] && $parent == 0) {
+  if (isset($params['root_term']) && $params['root_term'] && $parent == 0) {
     return array();
   }
 
@@ -368,7 +367,7 @@ function hs_taxonomy_hierarchical_select
 function hs_taxonomy_hierarchical_select_lineage($item, $params) {
   $lineage = array();
 
-  if ($params['root_term'] && $item == 0) {
+  if (isset($params['root_term']) && $params['root_term'] && $item == 0) {
     return array(0);
   }
 
@@ -383,10 +382,10 @@ function hs_taxonomy_hierarchical_select
  * Implementation of hook_hierarchical_select_valid_item().
  */
 function hs_taxonomy_hierarchical_select_valid_item($item, $params) {
-  if ($params['root_term'] && $item == 0) {
+  if (isset($params['root_term']) && $params['root_term'] && $item == 0) {
     return TRUE;
   }
-  else if (!is_numeric($item) || $item < 1 || $item == $params['exclude_tid']) {
+  else if (!is_numeric($item) || $item < 1 || (isset($params['exclude_tid']) && $item == $params['exclude_tid'])) {
     return FALSE;
   }
   $term = taxonomy_get_term($item);
@@ -698,7 +697,7 @@ function _hs_taxonomy_hierarchical_selec
   }
 
   $max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
-  if ($children[$vid][$parent]) {
+  if (isset($children[$vid][$parent])) {
     foreach ($children[$vid][$parent] as $child) {
       if ($max_depth > $depth) {
         $term = drupal_clone($terms[$vid][$child]);
@@ -708,14 +707,14 @@ function _hs_taxonomy_hierarchical_selec
         $term->parents = $parents[$vid][$child];
         $tree[] = $term;
 
-        if ($children[$vid][$child]) {
+        if (isset($children[$vid][$child])) {
           $tree = array_merge($tree, _hs_taxonomy_hierarchical_select_get_tree($vid, $child, $depth, $max_depth));
         }
       }
     }
   }
 
-  return $tree ? $tree : array();
+  return isset($tree) ? $tree : array();
 }
 
 /**
@@ -775,6 +774,7 @@ function _hs_taxonomy_hierarchical_selec
  *   The depth of the vocabulary's tree.
  */
 function _hs_taxonomy_hierarchical_select_get_depth($vid) {
+  $depth = -99999;
   $tree = _hs_taxonomy_hierarchical_select_get_tree($vid);
   foreach ($tree as $term) {
     if ($term->depth > $depth) {
Index: modules/hs_taxonomy_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hierarchical_select/modules/hs_taxonomy_views.module,v
retrieving revision 1.21
diff -u -F '^f' -r1.21 hs_taxonomy_views.module
--- modules/hs_taxonomy_views.module	21 Sep 2009 11:49:03 -0000	1.21
+++ modules/hs_taxonomy_views.module	30 Oct 2009 18:31:43 -0000
@@ -272,6 +272,7 @@ function hs_taxonomy_views_config_form($
     'exclude_tid' => NULL,
     'root_term'   => NULL,
   );
+  $vocabulary = taxonomy_vocabulary_load($params['vid']);
   $defaults = array(
     // Enable the save_lineage setting by default if the multiple parents
     // vocabulary option is enabled.
@@ -297,7 +298,7 @@ function hs_taxonomy_views_config_form($
     'entities'    => t('nodes'),
   );
   $max_hierarchy_depth = _hs_taxonomy_hierarchical_select_get_depth($vocabulary->vid);
-  $preview_is_required = !(bool)$exposed_filter['expose']['optional'];
+  $preview_is_required = !(bool)$filter['expose']['optional'];
   $form['hierarchical_select_config'] = hierarchical_select_common_config_form($module, $params, $config_id, $defaults, $strings, $max_hierarchy_depth, $preview_is_required);
 
   $form['link'] = array(
@@ -502,20 +503,22 @@ function hs_taxonomy_views_hierarchical_
     $count_query = str_replace("SELECT node.nid AS nid", "SELECT DISTINCT(node.nid) AS nid", $count_query);
 
     // Filter by node type if such a filter is configured in the view.
-    $node_types = $current_view->filter['type']->value;
-    if (isset($node_types)) {
-      $values = '';
-      foreach ($node_types as $key => $value) {
-        if (empty($values)) {
-          $values = '\''. $value .'\'';
-        }
-        else {
-          $values .= ', \''. $value .'\'';
+    if (isset($current_view->filter['type'])) {
+      $node_types = $current_view->filter['type']->value;
+      if (isset($node_types)) {
+        $values = '';
+        foreach ($node_types as $key => $value) {
+          if (empty($values)) {
+            $values = '\''. $value .'\'';
+          }
+          else {
+            $values .= ', \''. $value .'\'';
+          }
         }
-      }
 
-      // Use the same sneaky string replace trick once more.
-      $count_query = str_replace("WHERE", 'WHERE node.type IN (' . $values . ') AND', $count_query);
+        // Use the same sneaky string replace trick once more.
+        $count_query = str_replace("WHERE", 'WHERE node.type IN (' . $values . ') AND', $count_query);
+      }
     }
 
     // Apply the same query transformations as view::execute() does.
@@ -548,13 +551,16 @@ function hs_taxonomy_views_hierarchical_
 
   foreach ($views as $view) {
     foreach (array_keys($view->display) as $display_id) {
-      if (count($view->display[$display_id]->display_options['filters'])) {
+      if (isset($view->display[$display_id]->display_options['filters']) && count($view->display[$display_id]->display_options['filters'])) {
         foreach ($view->display[$display_id]->display_options['filters'] as $filter) {
-          if ($filter['type'] == 'hierarchical_select' && $filter['table'] == 'term_node' && $filter['field'] == 'tid') {
+          if (isset($filter['type']) && $filter['type'] == 'hierarchical_select'
+              && isset($filter['table']) && $filter['table'] == 'term_node'
+              && isset($filter['field']) && $filter['field'] == 'tid')
+          {
             $vocabulary = taxonomy_vocabulary_load($filter['vid']);
             $filter_label = (!empty($filter['expose']['label'])) ? $filter['expose']['label'] : t('Taxonomy: Term');
 
-            $config_id = "taxonomy-views-$view->name-$vocabulary->vid";
+            $config_id = "taxonomy-views-$view->name-$display_id-{$filter['id']}";
             $config_info[$config_id] = array(
               'config_id'      => $config_id,
               'hierarchy type' => t('Taxonomy'),
