From e013bf2029491e624c22960e0345155577a4166a Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 5 Sep 2019 10:04:42 +1200 Subject: [PATCH] Move default fetching to Processor class --- CRM/Contact/Import/Form/MapField.php | 9 ++------- CRM/Import/ImportProcessor.php | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 21254b6a85..4b926c314f 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -886,14 +886,9 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { $locationId = $processor->getLocationTypeID($i); $phoneType = $processor->getPhoneTypeID($i); $imProvider = $processor->getIMProviderID($i); - $typeId = $processor->getPhoneOrIMTypeID($i); - if ($websiteTypeId) { - $defaults["mapper[$i]"] = [$relation, $contactDetails, $websiteTypeId]; - } - else { - - $defaults["mapper[$i]"] = [$relation, $contactDetails, $locationId, $typeId]; + $defaults["mapper[$i]"] = $processor->getSavedQuickformDefaultsForColumn($i); + if (!$websiteTypeId) { if (!$locationId) { $js .= "{$formName}['mapper[$i][2]'].style.display = 'none';\n"; } diff --git a/CRM/Import/ImportProcessor.php b/CRM/Import/ImportProcessor.php index 5640c837a9..035591c446 100644 --- a/CRM/Import/ImportProcessor.php +++ b/CRM/Import/ImportProcessor.php @@ -513,6 +513,12 @@ class CRM_Import_ImportProcessor { * @throws \CiviCRM_API3_Exception */ public function getSavedQuickformDefaultsForColumn($column) { + if ($this->getValidRelationshipKey($column)) { + if ($this->getWebsiteTypeID($column)) { + return [$this->getValidRelationshipKey($column), $this->getFieldName($column), $this->getWebsiteTypeID($column)]; + } + return [$this->getValidRelationshipKey($column), $this->getFieldName($column), $this->getLocationTypeID($column), $this->getPhoneOrIMTypeID($column)]; + } if ($this->getWebsiteTypeID($column)) { return [$this->getFieldName($column), $this->getWebsiteTypeID($column)]; } -- 2.25.1