From d58a19a1be18ffd3c8124acaddbeb4cc1e873cdf Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 6 Jan 2015 13:09:20 -0800 Subject: [PATCH] INFRA-132 - CRM/Dedupe - phpcbf --- CRM/Dedupe/BAO/QueryBuilder.php | 4 ++-- CRM/Dedupe/BAO/RuleGroup.php | 4 +--- CRM/Dedupe/Finder.php | 14 +++++++----- CRM/Dedupe/Merger.php | 40 +++++++++++++++------------------ 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/CRM/Dedupe/BAO/QueryBuilder.php b/CRM/Dedupe/BAO/QueryBuilder.php index ed57379465..5607c5d4df 100644 --- a/CRM/Dedupe/BAO/QueryBuilder.php +++ b/CRM/Dedupe/BAO/QueryBuilder.php @@ -11,11 +11,11 @@ class CRM_Dedupe_BAO_QueryBuilder { * * @return string */ - public static function internalFilters( $rg, $strID1 = 'contact1.id', $strID2 = 'contact2.id' ) { + public static function internalFilters($rg, $strID1 = 'contact1.id', $strID2 = 'contact2.id') { // Add a contact id filter for dedupe by group requests and add logic // to remove duplicate results with opposing orders, i.e. 1,2 and 2,1 if( !empty($rg->contactIds) ) { - $cids = implode(',',$rg->contactIds); + $cids = implode(',', $rg->contactIds); return "($strID1 IN ($cids) AND ( $strID2 NOT IN ($cids) OR ($strID2 IN ($cids) AND $strID1 < $strID2) ))"; } else { diff --git a/CRM/Dedupe/BAO/RuleGroup.php b/CRM/Dedupe/BAO/RuleGroup.php index d0baaca500..b181534e7b 100644 --- a/CRM/Dedupe/BAO/RuleGroup.php +++ b/CRM/Dedupe/BAO/RuleGroup.php @@ -198,7 +198,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { $dao = new CRM_Core_DAO(); $dao->query($tempTableQuery); - CRM_Utils_Hook::dupeQuery($this, 'table', $tableQueries); while (!empty($tableQueries)) { @@ -447,8 +446,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { $result = array(); while ($dao->fetch()) { $title = - !empty($dao->title) ? $dao->title : - (!empty($dao->name) ? $dao->name : $dao->contact_type); + !empty($dao->title) ? $dao->title : (!empty($dao->name) ? $dao->name : $dao->contact_type); $name = "$title - {$dao->used}"; $result[$dao->id] = $name; diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index 2e123ebd80..467c1a266f 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -95,8 +95,8 @@ class CRM_Dedupe_Finder { */ static function dupesByParams($params, $ctype, - $used = 'Unsupervised', - $except = array(), + $used = 'Unsupervised', + $except = array(), $ruleGroupID = NULL ) { // If $params is empty there is zero reason to proceed. @@ -151,8 +151,8 @@ class CRM_Dedupe_Finder { public static function dupesInGroup($rgid, $gid) { $cids = array_keys(CRM_Contact_BAO_Group::getMember($gid)); if ( !empty($cids) ) { - return self::dupes($rgid, $cids); - } + return self::dupes($rgid, $cids); + } return array(); } @@ -299,8 +299,10 @@ class CRM_Dedupe_Finder { $fields['location_type_id'] = ''; // FIXME: we also need to do some hacking for id and name fields, see CRM-3902’s comments $fixes = array( - 'address_name' => 'name', 'country' => 'country_id', - 'state_province' => 'state_province_id', 'county' => 'county_id', + 'address_name' => 'name', + 'country' => 'country_id', + 'state_province' => 'state_province_id', + 'county' => 'county_id', ); foreach ($fixes as $orig => $target) { if (!empty($flat[$orig])) { diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index d94127d5b0..cfef7dd500 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -378,28 +378,28 @@ INNER JOIN civicrm_participant participant ON ( participant.id = payment.partic return $sqls; } - switch ($tableName) { case 'civicrm_membership': - if (array_key_exists($tableName, $tableOperations) && $tableOperations[$tableName]['add']) - break; - if ($mode == 'add') { - $sqls[] = " + if (array_key_exists($tableName, $tableOperations) && $tableOperations[$tableName]['add']) { + break; + } + if ($mode == 'add') { + $sqls[] = " DELETE membership1.* FROM civicrm_membership membership1 INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = membership2.membership_type_id AND membership1.contact_id = {$mainId} AND membership2.contact_id = {$otherId} "; - } - if ($mode == 'payment') { - $sqls[] = " + } + if ($mode == 'payment') { + $sqls[] = " DELETE contribution.* FROM civicrm_contribution contribution INNER JOIN civicrm_membership_payment payment ON payment.contribution_id = contribution.id INNER JOIN civicrm_membership membership1 ON membership1.id = payment.membership_id AND membership1.contact_id = {$mainId} INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = membership2.membership_type_id AND membership2.contact_id = {$otherId}"; - } - break; + } + break; case 'civicrm_uf_match': // normal queries won't work for uf_match since that will lead to violation of unique constraint, @@ -565,7 +565,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m * Helps decide how to behave when there are conflicts. * A 'safe' value skips the merge if there are any un-resolved conflicts. * Does a force merge otherwise. - * @param boolean $autoFlip + * @param bool $autoFlipWether to let api decide which contact to retain and which to delete. * Wether to let api decide which contact to retain and which to delete. * @param bool $redirectForPerformance * @@ -611,7 +611,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m * Helps decide how to behave when there are conflicts. * A 'safe' value skips the merge if there are any un-resolved conflicts. * Does a force merge otherwise (aggressive mode). - * @param boolean $autoFlip + * @param bool $autoFlipWether to let api decide which contact to retain and which to delete. * Wether to let api decide which contact to retain and which to delete. * * @@ -850,10 +850,8 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m ); if (!empty($contact['preferred_communication_method'])){ - // api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct - $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? - implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : - $specialValues[$moniker]['preferred_communication_method']; + // api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct + $prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : $specialValues[$moniker]['preferred_communication_method']; $specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR; } $names = array( @@ -1175,9 +1173,9 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m ); if ($values['data'] === 0 || $values['data'] === '0') { $values['data'] = $qfZeroBug; - } + } $value = ($values['data']) ? $values['data'] : $value; - } + } } $rows["move_custom_$fid"]['title'] = $field['label']; @@ -1261,7 +1259,6 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m } } - // **** Do location related migration: if (!empty($locBlocks)) { $locComponent = array( @@ -1297,7 +1294,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m } if (isset($migrationInfo['main_details']['loc_block_ids'][$name])) { - $mainBlockId = CRM_Utils_Array::value($idKey, $migrationInfo['main_details']['loc_block_ids'][$name]); + $mainBlockId = CRM_Utils_Array::value($idKey, $migrationInfo['main_details']['loc_block_ids'][$name]); } if (!$otherBlockId) { @@ -1490,7 +1487,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m // move the other contact's file to main contact //NYSS need to INSERT or UPDATE depending on whether main contact has an existing record if ( CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}") ) { - $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}"; + $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}"; } else { $sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )"; @@ -1554,7 +1551,6 @@ 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'])) { -- 2.25.1