Move greeting params retrieval to the place in the code where it is used
authoreileen <emcnaughton@wikimedia.org>
Tue, 9 Jul 2019 21:28:42 +0000 (09:28 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 9 Jul 2019 21:30:28 +0000 (09:30 +1200)
CRM/Export/BAO/Export.php
CRM/Export/Form/Map.php
CRM/Export/Form/Select.php

index 3b5c5c4c03179460a5cc0d12cc37a1825f3ed374..f3431116119d3e16dc8f2e06dc1c0b30b776f1c5 100644 (file)
@@ -609,6 +609,24 @@ VALUES $sqlValueString
    * @param array $exportParams
    */
   public static function mergeSameAddress($processor, &$sqlColumns, $exportParams) {
+    $greetingOptions = CRM_Export_Form_Select::getGreetingOptions();
+
+    if (!empty($greetingOptions)) {
+      // Greeting options is keyed by 'postal_greeting' or 'addressee'.
+      foreach ($greetingOptions as $key => $value) {
+        if ($option = CRM_Utils_Array::value($key, $exportParams)) {
+          if ($greetingOptions[$key][$option] == ts('Other')) {
+            $exportParams[$key] = $exportParams["{$key}_other"];
+          }
+          elseif ($greetingOptions[$key][$option] == ts('List of names')) {
+            $exportParams[$key] = '';
+          }
+          else {
+            $exportParams[$key] = $greetingOptions[$key][$option];
+          }
+        }
+      }
+    }
     $tableName = $processor->getTemporaryTable();
     // check if any records are present based on if they have used shared address feature,
     // and not based on if city / state .. matches.
index 60d6002dff2ce919b62514a06471ef96181b8c5a..ea955205cb4a323f406e024d77161d1bbfa175cf 100644 (file)
@@ -159,24 +159,6 @@ class CRM_Export_Form_Map extends CRM_Core_Form {
     $params = $this->controller->exportValues($this->_name);
     $exportParams = $this->controller->exportValues('Select');
 
-    $greetingOptions = CRM_Export_Form_Select::getGreetingOptions();
-
-    if (!empty($greetingOptions)) {
-      foreach ($greetingOptions as $key => $value) {
-        if ($option = CRM_Utils_Array::value($key, $exportParams)) {
-          if ($greetingOptions[$key][$option] == ts('Other')) {
-            $exportParams[$key] = $exportParams["{$key}_other"];
-          }
-          elseif ($greetingOptions[$key][$option] == ts('List of names')) {
-            $exportParams[$key] = '';
-          }
-          else {
-            $exportParams[$key] = $greetingOptions[$key][$option];
-          }
-        }
-      }
-    }
-
     $currentPath = CRM_Utils_System::currentPath();
 
     $urlParams = NULL;
index 7395ac1672f9e822ec904eae6513e43e1c8f83bc..315c622cb146d3c824729b10c0686e393204b2f5 100644 (file)
@@ -388,22 +388,6 @@ FROM   {$this->_componentTable}
     // all submitted options or any other argument
     $exportParams = $params;
 
-    if (!empty($this->_greetingOptions)) {
-      foreach ($this->_greetingOptions as $key => $value) {
-        if ($option = CRM_Utils_Array::value($key, $exportParams)) {
-          if ($this->_greetingOptions[$key][$option] == ts('Other')) {
-            $exportParams[$key] = $exportParams["{$key}_other"];
-          }
-          elseif ($this->_greetingOptions[$key][$option] == ts('List of names')) {
-            $exportParams[$key] = '';
-          }
-          else {
-            $exportParams[$key] = $this->_greetingOptions[$key][$option];
-          }
-        }
-      }
-    }
-
     $mappingId = CRM_Utils_Array::value('mapping', $params);
     if ($mappingId) {
       $this->set('mappingId', $mappingId);