commit 51cc509a276ccf97f7a2135edac78fd6aa77b934
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Tue Jun 28 14:54:08 2016 +0200

    #5890 pass classification root node uuid as argument to autosuggest
    function

diff --git a/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module b/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
index 5b7da419..0e5569ca 100644
--- a/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
+++ b/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
@@ -73,6 +73,14 @@ function cdm_csv_export_block_view($delta='') {
   return $block;
 }
 
+function taxon_selection_update($form, &$form_state) {
+  unset($form_state['input']['taxon_select'], $form_state['values']['taxon_select']);
+  $tree = $form_state['input']['taxonNode'];
+  $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest/'.$tree.'///';
+  $form['taxon_select']['#value'] = '';
+  return form_builder($form['#id'], $form['taxon_select'], $form_state);
+}
+
 /**
  * Creates the drupal form and returns it
  *
@@ -81,21 +89,33 @@ function cdm_csv_export_block_view($delta='') {
  *
  */
 function cdm_csv_export_my_form($form_state) {
+    $tree = variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
     $form['combobox'] = array(
         '#type' => 'select',
         '#title' => t('Classification').':',
-        '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
+        '#default_value' => $tree,
         '#options' => cdm_get_taxontrees_as_options(FALSE, TRUE),
         '#attributes' => array(
             'name' => 'taxonNode',
-            'onchange' => 'return validateForm()'),
+            'onchange' => 'return validateForm()'
+        ),
+        '#ajax' => array(
+          'callback' => 'taxon_selection_update',
+          'wrapper' => 'taxon-selection',
+          'progress' => array(
+            'message' => '',
+            'type' => 'throbber',
+          ),
+        )
     );
     $form['taxon_select'] = array(
         '#title' => t('Taxon'),
         '#type' => 'textfield',
+        '#prefix' => '<div id="taxon-selection">',
+        '#suffix' => '</div>'
     );
     if(variable_get('cdm_dataportal_taxon_auto_suggest')){
-        $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest';
+        $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest////';
     }
 
     $form['redListField'] = array(
diff --git a/modules/cdm_dataportal/cdm_dataportal.module b/modules/cdm_dataportal/cdm_dataportal.module
index 2281cf9f..1b86d7e6 100644
--- a/modules/cdm_dataportal/cdm_dataportal.module
+++ b/modules/cdm_dataportal/cdm_dataportal.module
@@ -611,9 +611,10 @@ function cdm_dataportal_menu() {
     , // Expected callback arguments: taxon_uuid.
     );
 
-    $items['cdm_dataportal/taxon/autosuggest'] = array(
+    $items['cdm_dataportal/taxon/autosuggest/%/%/%/'] = array(
         'page callback' => 'cdm_dataportal_taxon_autosuggest',
         'access arguments' => array('access taxon autosuggest'),
+        'page arguments' => array(3,4,5),
         'type' => MENU_CALLBACK
     );
   }
diff --git a/modules/cdm_dataportal/cdm_dataportal.search.php b/modules/cdm_dataportal/cdm_dataportal.search.php
index efaf67fe..5948f21d 100644
--- a/modules/cdm_dataportal/cdm_dataportal.search.php
+++ b/modules/cdm_dataportal/cdm_dataportal.search.php
@@ -121,7 +121,7 @@ function cdm_dataportal_search_form_prepare($action_path, $search_webservice, $q
   return $form;
 }
 
-function cdm_dataportal_taxon_autosuggest($string, $treeUuid = NULL, $areaUuid = NULL, $status = NULL) {
+function cdm_dataportal_taxon_autosuggest($treeUuid = NULL, $areaUuid = NULL, $status = NULL, $string) {
   $matches = array();
 
   $queryParams = array();
@@ -136,7 +136,7 @@ function cdm_dataportal_taxon_autosuggest($string, $treeUuid = NULL, $areaUuid =
     $queryParams['status'] = $status ;
   }
   $queryParams['pageNumber'] = '0';
-  $queryParams['pageSize'] = '10';
+  $queryParams['pageSize'] = '100';
   $queryParams['doTaxa'] = true;
   $queryParams['doSynonyms'] = true;
   $queryParams['doMisappliedNames'] = true;
@@ -147,7 +147,7 @@ function cdm_dataportal_taxon_autosuggest($string, $treeUuid = NULL, $areaUuid =
       $titleCache = $record->entity->titleCache;
       preg_match('/(.*) sec.*/', $titleCache, $trimmedTitle); //remove sec reference
       $trimmedTitle = trim($trimmedTitle[1]);
-      $matches[$trimmedTitle] = $trimmedTitle;
+      $matches[$trimmedTitle] = check_plain($trimmedTitle);
   }
   drupal_json_output($matches);
 }
