From 5790f42f29f708c5794024797927a8ebd1bfea61 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 10 Jul 2019 09:28:42 +1200 Subject: [PATCH] Move greeting params retrieval to the place in the code where it is used --- CRM/Export/BAO/Export.php | 18 ++++++++++++++++++ CRM/Export/Form/Map.php | 18 ------------------ CRM/Export/Form/Select.php | 16 ---------------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 3b5c5c4c03..f343111611 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -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. diff --git a/CRM/Export/Form/Map.php b/CRM/Export/Form/Map.php index 60d6002dff..ea955205cb 100644 --- a/CRM/Export/Form/Map.php +++ b/CRM/Export/Form/Map.php @@ -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; diff --git a/CRM/Export/Form/Select.php b/CRM/Export/Form/Select.php index 7395ac1672..315c622cb1 100644 --- a/CRM/Export/Form/Select.php +++ b/CRM/Export/Form/Select.php @@ -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); -- 2.25.1