From 674920ca77348c0fa54ca14018f5b07dee9df31f Mon Sep 17 00:00:00 2001 From: Eaiman Shoshi Date: Fri, 28 Jul 2017 16:29:56 +0600 Subject: [PATCH] Indentation fixed PhpStorm's tabs are now fixed to spaces. --- CRM/Dedupe/Merger.php | 104 +++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 9ff8398e57..fc98728b42 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -446,15 +446,15 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $paymentTables = self::paymentTables(); // CRM-12695: $membershipMerge = FALSE; - + // getting all custom tables - $customTables = []; - if($customTableToCopyFrom != NULL) { - self::addCustomTablesExtendingContactsToCidRefs($customTables); - $customTables = array_keys($customTables); - } - - $affected = array_merge(array_keys($cidRefs), array_keys($eidRefs)); + $customTables = array(); + if ($customTableToCopyFrom != NULL) { + self::addCustomTablesExtendingContactsToCidRefs($customTables); + $customTables = array_keys($customTables); + } + + $affected = array_merge(array_keys($cidRefs), array_keys($eidRefs)); if ($tables !== FALSE) { // if there are specific tables, sanitize the list $affected = array_unique(array_intersect($affected, $tables)); @@ -491,12 +491,11 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $sqls = array(); foreach ($affected as $table) { - // skipping non selected custom table's value migration - if($customTableToCopyFrom != NULL && in_array($table, $customTables) - && !in_array($table, $customTableToCopyFrom)){ + // skipping non selected custom table's value migration + if ($customTableToCopyFrom != NULL && in_array($table, $customTables) && !in_array($table, $customTableToCopyFrom)) { continue; } - + // Call custom processing function for objects that require it if (isset($cpTables[$table])) { foreach ($cpTables[$table] as $className => $fnName) { @@ -1517,50 +1516,49 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m unset($moveTables, $tableOperations); } - // capturing the custom table names. The table's value we have to merge - // from duplicate contact to original contact + // capturing the custom table names. The table's value we have to merge + // from duplicate contact to original contact $customTableToCopyValues = array(); - foreach ($submittedCustomValue as $value){ - if($value != NULL) { - $result1 = null; - try { - $result1 = civicrm_api3('custom_field', 'get', [ - 'id' => $value, - 'is_active' => TRUE - ]); - } catch (CiviCRM_API3_Exception $e) { - // just ignore and continue - continue; + foreach ($submittedCustomValue as $value) { + if ($value != NULL) { + $result1 = NULL; + try { + $result1 = civicrm_api3('custom_field', 'get', [ + 'id' => $value, + 'is_active' => TRUE + ]); + } + catch (CiviCRM_API3_Exception $e) { + // just ignore and continue + continue; } - if (!civicrm_error($result1) - && isset($result1['values']) && is_array($result1['values'])) { - foreach ($result1['values'] as $value1) { - if ($value1 != NULL && is_array($value1) && isset($value1['custom_group_id'])) { - $result2 = null; - try { - $result2 = civicrm_api3('custom_group', 'get', [ - 'id' => $value1['custom_group_id'], - 'is_active' => TRUE - ]); - }catch (CiviCRM_API3_Exception $e) { - // just ignore and continue - continue; - } - if (!civicrm_error($result2) - && isset($result2['values']) && is_array($result2['values']) - ) { - foreach ($result2['values'] as $value2) { - if ($value2 != NULL && is_array($value2) && isset($value2['table_name'])) { - array_push($customTableToCopyValues, $value2['table_name']); - } - } + if (!civicrm_error($result1) && isset($result1['values']) && is_array($result1['values'])) { + foreach ($result1['values'] as $value1) { + if ($value1 != NULL && is_array($value1) && isset($value1['custom_group_id'])) { + $result2 = NULL; + try { + $result2 = civicrm_api3('custom_group', 'get', [ + 'id' => $value1['custom_group_id'], + 'is_active' => TRUE + ]); } - } - } - } - } - } - + catch (CiviCRM_API3_Exception $e) { + // just ignore and continue + continue; + } + if (!civicrm_error($result2) && isset($result2['values']) && is_array($result2['values'])) { + foreach ($result2['values'] as $value2) { + if ($value2 != NULL && is_array($value2) && isset($value2['table_name'])) { + array_push($customTableToCopyValues, $value2['table_name']); + } + } + } + } + } + } + } + } + // **** Do contact related migrations CRM_Dedupe_Merger::moveContactBelongings($mainId, $otherId, FALSE, array(), $customTableToCopyValues); -- 2.25.1