From 402c5c5fca33c14e2cc517679310985fe55aa297 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 11 Jan 2023 18:07:34 +1300 Subject: [PATCH] Use meaningful variable names --- CRM/Contact/Import/Form/MapField.php | 41 ++++++++++++---------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index da82e22562..cee463fbfa 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -171,19 +171,12 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { $id = $first = $second = NULL; } if (($first === 'a' && $second === 'b') || ($first === 'b' && $second === 'a')) { - $cType = $contactRelationCache[$id]["contact_type_$second"]; + $relatedContactType = $contactRelationCache[$id]["contact_type_$second"] ?: 'All'; //CRM-5125 for contact subtype specific RelationshipTypes - $cSubType = NULL; - if (!empty($contactRelationCache[$id]["contact_sub_type_$second"])) { - $cSubType = $contactRelationCache[$id]["contact_sub_type_$second"]; - } - - if (!$cType) { - $cType = 'All'; - } + $relatedContactSubType = $contactRelationCache[$id]["contact_sub_type_$second"] ?? NULL; - $relatedFields = CRM_Contact_BAO_Contact::importableFields($cType); + $relatedFields = CRM_Contact_BAO_Contact::importableFields($relatedContactType); unset($relatedFields['']); $values = []; foreach ($relatedFields as $name => $field) { @@ -200,39 +193,39 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { } //fix to append custom group name to field name, CRM-2676 - if (empty($this->_formattedFieldNames[$cType]) || $cType === $this->getContactType()) { - $this->_formattedFieldNames[$cType] = $this->formatCustomFieldName($values); + if (empty($this->_formattedFieldNames[$relatedContactType]) || $relatedContactType === $this->getContactType()) { + $this->_formattedFieldNames[$relatedContactType] = $this->formatCustomFieldName($values); } - $this->_formattedFieldNames[$cType] = array_merge($values, $this->_formattedFieldNames[$cType]); + $this->_formattedFieldNames[$relatedContactType] = array_merge($values, $this->_formattedFieldNames[$relatedContactType]); //Modified the Relationship fields if the fields are //present in dedupe rule - if ($this->isIgnoreDuplicates() && !empty($this->_dedupeFields[$cType]) && - is_array($this->_dedupeFields[$cType]) + if ($this->isIgnoreDuplicates() && !empty($this->_dedupeFields[$relatedContactType]) && + is_array($this->_dedupeFields[$relatedContactType]) ) { static $cTypeArray = []; - if ($cType !== $this->getContactType() && !in_array($cType, $cTypeArray)) { - foreach ($this->_dedupeFields[$cType] as $val) { - if ($valTitle = CRM_Utils_Array::value($val, $this->_formattedFieldNames[$cType])) { - $this->_formattedFieldNames[$cType][$val] = $valTitle . ' (match to contact)'; + if ($relatedContactType !== $this->getContactType() && !in_array($relatedContactType, $cTypeArray)) { + foreach ($this->_dedupeFields[$relatedContactType] as $val) { + if ($valTitle = CRM_Utils_Array::value($val, $this->_formattedFieldNames[$relatedContactType])) { + $this->_formattedFieldNames[$relatedContactType][$val] = $valTitle . ' (match to contact)'; } } - $cTypeArray[] = $cType; + $cTypeArray[] = $relatedContactType; } } foreach ($highlightedFields as $k => $v) { - if ($v === $cType || $v === 'All') { + if ($v === $relatedContactType || $v === 'All') { $highlightedRelFields[$key][] = $k; } } $this->assign('highlightedRelFields', $highlightedRelFields); - $sel2[$key] = $this->_formattedFieldNames[$cType]; + $sel2[$key] = $this->_formattedFieldNames[$relatedContactType]; - if (!empty($cSubType)) { + if (!empty($relatedContactSubType)) { //custom fields for sub type - $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($cSubType); + $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($relatedContactSubType); if (!empty($subTypeFields)) { $subType = NULL; -- 2.25.1