From 4d5f18cc7845b8277bff01cac7108686a7adc4e3 Mon Sep 17 00:00:00 2001 From: aydun Date: Thu, 4 Dec 2014 17:52:37 +0000 Subject: [PATCH] CRM-15681 Merge sub-types Merge sub-types, don't display sub-types in merge UI Remove unneeded code for displaying sub-types --- CRM/Dedupe/Merger.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 4c273c795c..3bcc2abe02 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -811,9 +811,6 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m CRM_Core_DAO::freeResult(); } - // get all contact subtypes - $contactSubTypes = CRM_Contact_BAO_ContactType::subTypePairs(NULL, TRUE, ''); - // FIXME: there must be a better way foreach (array('main', 'other') as $moniker) { $contact = &$$moniker; @@ -821,7 +818,6 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $value = empty($preferred_communication_method) ? array() : $preferred_communication_method; $specialValues[$moniker] = array( 'preferred_communication_method' => $value, - 'contact_sub_type' => $value, 'communication_style_id' => $value, ); @@ -841,17 +837,6 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m ); CRM_Core_OptionGroup::lookupValues($specialValues[$moniker], $names); - if (!empty($contact['contact_sub_type'])) { - $specialValues[$moniker]['contact_sub_type'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $contact['contact_sub_type']); - - // fix contact sub type label for contact with sub type - $subtypes = array(); - foreach ($contact['contact_sub_type'] as $key => $value) { - $subtypes[] = CRM_Utils_Array::retrieveValueRecursive($contactSubTypes, $value); - } - $contact['contact_sub_type_display'] = $specialValues[$moniker]['contact_sub_type_display'] = implode(', ', $subtypes); - } - if (!empty($contact['communication_style'])) { $specialValues[$moniker]['communication_style_id_display'] = $contact['communication_style']; } @@ -870,6 +855,10 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $rows = $elements = $relTableElements = $migrationInfo = array(); foreach ($diffs['contact'] as $field) { + if ($field == 'contact_sub_type') { + // CRM-15681 don't display sub-types in UI + continue; + } foreach (array('main', 'other') as $moniker) { $contact = &$$moniker; $value = CRM_Utils_Array::value($field, $contact); @@ -1529,6 +1518,15 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m /* } */ + // CRM-15681 merge sub_types + if ($other_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['other_details'])) { + if ($main_sub_types = CRM_Utils_array::value('contact_sub_type', $migrationInfo['main_details'])) { + $submitted['contact_sub_type'] = array_unique( array_merge($main_sub_types, $other_sub_types)); + } else { + $submitted['contact_sub_type'] = $other_sub_types; + } + } + // **** Update contact related info for the main contact if (!empty($submitted)) { $submitted['contact_id'] = $mainId; -- 2.25.1