Move default fetching to Processor class
authoreileen <emcnaughton@wikimedia.org>
Wed, 4 Sep 2019 22:04:42 +0000 (10:04 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 4 Sep 2019 22:04:42 +0000 (10:04 +1200)
CRM/Contact/Import/Form/MapField.php
CRM/Import/ImportProcessor.php

index 21254b6a8591ce2ad8e9c272aeb9daeafa30fb03..4b926c314fed2b5e0c94fba9859f06aaa652cb8d 100644 (file)
@@ -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";
             }
index 5640c837a96dca89110cfea857139793be87286a..035591c4465c68641662cdc923d92f13862e796b 100644 (file)
@@ -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)];
     }