Merge pull request #18143 from mattwire/membertabbuttons
[civicrm-core.git] / CRM / Import / ImportProcessor.php
index 929be2055159969b8549fe3feb4fe1a5b7d20fc9..27508e0aea17170f0993bdf9d7dca212e1ba5d24 100644 (file)
@@ -112,8 +112,8 @@ class CRM_Import_ImportProcessor {
    *
    * @param string $contactSubType
    */
-  public function setContactSubType(string $contactSubType) {
-    $this->contactSubType = $contactSubType;
+  public function setContactSubType($contactSubType) {
+    $this->contactSubType = (string) $contactSubType;
   }
 
   /**
@@ -438,6 +438,10 @@ class CRM_Import_ImportProcessor {
       }
       else {
         // Honour legacy chaos factor.
+        if ($field['name'] === ts('- do not import -')) {
+          // This is why we save names not labels people....
+          $field['name'] = 'do_not_import';
+        }
         $fields[$index]['name'] = strtolower(str_replace(" ", "_", $field['name']));
         // fix for edge cases, CRM-4954
         if ($fields[$index]['name'] === 'image_url') {
@@ -484,6 +488,7 @@ class CRM_Import_ImportProcessor {
    */
   protected function getNameFromLabel($label) {
     $titleMap = array_flip($this->getMetadataTitles());
+    $label = str_replace(' (match to contact)', '', $label);
     return $titleMap[$label] ?? '';
   }
 
@@ -495,7 +500,7 @@ class CRM_Import_ImportProcessor {
    * @return bool
    */
   protected function isValidRelationshipKey($key) {
-    return !empty($this->getValidRelationships()[$key]) ? TRUE : FALSE;
+    return !empty($this->getValidRelationships()[$key]);
   }
 
   /**
@@ -508,7 +513,10 @@ class CRM_Import_ImportProcessor {
    */
   public function getQuickFormJSForField($column) {
     $columnNumbersToHide = [];
-    if ($this->getRelationshipKey($column)) {
+    if ($this->getFieldName($column) === 'do_not_import') {
+      $columnNumbersToHide = [1, 2, 3];
+    }
+    elseif ($this->getRelationshipKey($column)) {
       if (!$this->getWebsiteTypeID($column) && !$this->getLocationTypeID($column)) {
         $columnNumbersToHide[] = 2;
       }
@@ -545,6 +553,9 @@ class CRM_Import_ImportProcessor {
    * @throws \CiviCRM_API3_Exception
    */
   public function getSavedQuickformDefaultsForColumn($column) {
+    if ($this->getFieldName($column) === 'do_not_import') {
+      return [];
+    }
     if ($this->getValidRelationshipKey($column)) {
       if ($this->getWebsiteTypeID($column)) {
         return [$this->getValidRelationshipKey($column), $this->getFieldName($column), $this->getWebsiteTypeID($column)];