Merge pull request #14818 from totten/master-magic-cache
[civicrm-core.git] / CRM / Export / Form / Map.php
index 0d4b16235d5d1110f89a6819a296f6104f57b77e..38b961ae6b9d2743cc57416599a02f97222e0ff1 100644 (file)
@@ -94,22 +94,21 @@ class CRM_Export_Form_Map extends CRM_Core_Form {
     );
 
     $this->addButtons([
-        [
-          'type' => 'back',
-          'name' => ts('Previous'),
-        ],
-        [
-          'type' => 'next',
-          'name' => ts('Export'),
-          'spacing' => '          ',
-        ],
-        [
-          'type' => 'done',
-          'icon' => 'fa-times',
-          'name' => ts('Done'),
-        ],
-      ]
-    );
+      [
+        'type' => 'back',
+        'name' => ts('Previous'),
+      ],
+      [
+        'type' => 'next',
+        'name' => ts('Export'),
+        'spacing' => '          ',
+      ],
+      [
+        'type' => 'done',
+        'icon' => 'fa-times',
+        'name' => ts('Done'),
+      ],
+    ]);
   }
 
   /**
@@ -160,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;
@@ -202,14 +183,14 @@ class CRM_Export_Form_Map extends CRM_Core_Form {
 
     $mapperKeys = $params['mapper'][1];
 
-    $checkEmpty = 0;
-    foreach ($mapperKeys as $value) {
-      if ($value[0]) {
-        $checkEmpty++;
+    $mappedFields = [];
+    foreach ((array) $mapperKeys as $field) {
+      if (!empty($field[1])) {
+        $mappedFields[] = CRM_Core_BAO_Mapping::getMappingParams([], $field);
       }
     }
 
-    if (!$checkEmpty) {
+    if (!$mappedFields) {
       $this->set('mappingId', NULL);
       CRM_Utils_System::redirect(CRM_Utils_System::url($currentPath, '_qf_Map_display=true' . $urlParams));
     }
@@ -239,7 +220,7 @@ class CRM_Export_Form_Map extends CRM_Core_Form {
       $this->get('componentIds'),
       (array) $this->get('queryParams'),
       $this->get(CRM_Utils_Sort::SORT_ORDER),
-      $mapperKeys,
+      $mappedFields,
       $this->get('returnProperties'),
       $this->get('exportMode'),
       $this->get('componentClause'),