From 954d76e04f22b327d8391ebbbddd3dba044a046f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 19 May 2022 14:08:56 +1200 Subject: [PATCH] [Import] Remove if (1) { --- CRM/Contact/Import/Parser/Contact.php | 62 ++++++++++++--------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 00ae15f24f..cae7b3a311 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -346,39 +346,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $updateflag = TRUE; foreach ($matchedIDs as $contactId) { if ($params['id'] == $contactId) { - if (1) { - //validation of subtype for update mode - //CRM-5125 - $contactSubType = NULL; - if (!empty($params['contact_sub_type'])) { - $contactSubType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_sub_type'); - } - - if (!empty($contactSubType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params['id'], $contactSubType) && $contactSubType != CRM_Utils_Array::value('contact_sub_type', $formatted))) { - - $message = "Mismatched contact SubTypes :"; - array_unshift($values, $message); - $updateflag = FALSE; - $this->_retCode = CRM_Import_Parser::NO_MATCH; - } - else { - $updateflag = FALSE; - $this->_retCode = CRM_Import_Parser::VALID; - } - } - } - } - if ($updateflag) { - $message = "Mismatched contact IDs OR Mismatched contact Types :"; - array_unshift($values, $message); - $this->_retCode = CRM_Import_Parser::NO_MATCH; - } - } - } - else { - if (!empty($params['id'])) { - if (1) { - if (1) { //validation of subtype for update mode //CRM-5125 $contactSubType = NULL; @@ -390,14 +357,41 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $message = "Mismatched contact SubTypes :"; array_unshift($values, $message); + $updateflag = FALSE; $this->_retCode = CRM_Import_Parser::NO_MATCH; } else { - $newContact = $this->createContact($formatted, $contactFields, $onDuplicate, $params['id'], FALSE, $this->_dedupeRuleGroupID); + $updateflag = FALSE; $this->_retCode = CRM_Import_Parser::VALID; } } } + if ($updateflag) { + $message = "Mismatched contact IDs OR Mismatched contact Types :"; + array_unshift($values, $message); + $this->_retCode = CRM_Import_Parser::NO_MATCH; + } + } + } + else { + if (!empty($params['id'])) { + //validation of subtype for update mode + //CRM-5125 + $contactSubType = NULL; + if (!empty($params['contact_sub_type'])) { + $contactSubType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_sub_type'); + } + + if (!empty($contactSubType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params['id'], $contactSubType) && $contactSubType != CRM_Utils_Array::value('contact_sub_type', $formatted))) { + + $message = "Mismatched contact SubTypes :"; + array_unshift($values, $message); + $this->_retCode = CRM_Import_Parser::NO_MATCH; + } + else { + $newContact = $this->createContact($formatted, $contactFields, $onDuplicate, $params['id'], FALSE, $this->_dedupeRuleGroupID); + $this->_retCode = CRM_Import_Parser::VALID; + } } else { //CRM-4148 -- 2.25.1