From: eileen Date: Tue, 12 Jul 2016 05:01:04 +0000 (+1200) Subject: CRM-19035 fix UI to be consistent in dstID & srcID handling. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e67dcaf89df38e66149c6a808059637549ffc628;p=civicrm-core.git CRM-19035 fix UI to be consistent in dstID & srcID handling. Note this assumes the contact to keep stays on the left. Also note that after you flip a contact the merge link does not flip - this is not new --- diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 2da17695ea..4c1e37aa88 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -676,14 +676,14 @@ LIMIT {$offset}, {$rowCount} $nextParamKey = 3; $mappings = array( - 'src' => 'cc1.display_name', - 'dst' => 'cc2.display_name', - 'src_email' => 'ce1.email', - 'dst_email' => 'ce2.email', - 'src_postcode' => 'ca1.postal_code', - 'dst_postcode' => 'ca2.postal_code', - 'src_street' => 'ca1.street', - 'dst_street' => 'ca2.street', + 'dst' => 'cc1.display_name', + 'src' => 'cc2.display_name', + 'dst_email' => 'ce1.email', + 'src_email' => 'ce2.email', + 'dst_postcode' => 'ca1.postal_code', + 'src_postcode' => 'ca2.postal_code', + 'dst_street' => 'ca1.street', + 'src_street' => 'ca2.street', ); foreach ($mappings as $key => $dbName) { @@ -710,18 +710,18 @@ LIMIT {$offset}, {$rowCount} $join .= CRM_Dedupe_Merger::getJoinOnDedupeTable(); $select = array( - 'cc1.contact_type' => 'src_contact_type', - 'cc1.display_name' => 'src_display_name', - 'cc1.contact_sub_type' => 'src_contact_sub_type', - 'cc2.contact_type' => 'dst_contact_type', - 'cc2.display_name' => 'dst_display_name', - 'cc2.contact_sub_type' => 'dst_contact_sub_type', - 'ce1.email' => 'src_email', - 'ce2.email' => 'dst_email', - 'ca1.postal_code' => 'src_postcode', - 'ca2.postal_code' => 'dst_postcode', - 'ca1.street_address' => 'src_street', - 'ca2.street_address' => 'dst_street', + 'cc1.contact_type' => 'dst_contact_type', + 'cc1.display_name' => 'dst_display_name', + 'cc1.contact_sub_type' => 'dst_contact_sub_type', + 'cc2.contact_type' => 'src_contact_type', + 'cc2.display_name' => 'src_display_name', + 'cc2.contact_sub_type' => 'src_contact_sub_type', + 'ce1.email' => 'dst_email', + 'ce2.email' => 'src_email', + 'ca1.postal_code' => 'dst_postcode', + 'ca2.postal_code' => 'src_postcode', + 'ca1.street_address' => 'dst_street', + 'ca2.street_address' => 'src_street', ); if ($select) { @@ -745,35 +745,35 @@ LIMIT {$offset}, {$rowCount} if (!empty($columnDetails)) { switch ($columnDetails['data']) { case 'src': - $orderByClause = " ORDER BY cc1.display_name {$dir}"; + $orderByClause = " ORDER BY cc2.display_name {$dir}"; break; case 'src_email': - $orderByClause = " ORDER BY ce1.email {$dir}"; + $orderByClause = " ORDER BY ce2.email {$dir}"; break; case 'src_street': - $orderByClause = " ORDER BY ca1.street_address {$dir}"; + $orderByClause = " ORDER BY ca2.street_address {$dir}"; break; case 'src_postcode': - $orderByClause = " ORDER BY ca1.postal_code {$dir}"; + $orderByClause = " ORDER BY ca2.postal_code {$dir}"; break; case 'dst': - $orderByClause = " ORDER BY cc2.display_name {$dir}"; + $orderByClause = " ORDER BY cc1.display_name {$dir}"; break; case 'dst_email': - $orderByClause = " ORDER BY ce2.email {$dir}"; + $orderByClause = " ORDER BY ce1.email {$dir}"; break; case 'dst_street': - $orderByClause = " ORDER BY ca2.street_address {$dir}"; + $orderByClause = " ORDER BY ca1.street_address {$dir}"; break; case 'dst_postcode': - $orderByClause = " ORDER BY ca2.postal_code {$dir}"; + $orderByClause = " ORDER BY ca1.postal_code {$dir}"; break; default: @@ -786,29 +786,29 @@ LIMIT {$offset}, {$rowCount} $count = 0; foreach ($dupePairs as $key => $pairInfo) { - $pair =& $pairInfo['data']; + $pair = $pairInfo['data']; $srcContactSubType = CRM_Utils_Array::value('src_contact_sub_type', $pairInfo); $dstContactSubType = CRM_Utils_Array::value('dst_contact_sub_type', $pairInfo); $srcTypeImage = CRM_Contact_BAO_Contact_Utils::getImage($srcContactSubType ? $srcContactSubType : $pairInfo['src_contact_type'], FALSE, - $pairInfo['entity_id1'] + $pairInfo['entity_id2'] ); $dstTypeImage = CRM_Contact_BAO_Contact_Utils::getImage($dstContactSubType ? $dstContactSubType : $pairInfo['dst_contact_type'], FALSE, - $pairInfo['entity_id2'] + $pairInfo['entity_id1'] ); $searchRows[$count]['is_selected'] = $pairInfo['is_selected']; $searchRows[$count]['is_selected_input'] = ""; $searchRows[$count]['src_image'] = $srcTypeImage; - $searchRows[$count]['src'] = CRM_Utils_System::href($pair['srcName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id1']}"); + $searchRows[$count]['src'] = CRM_Utils_System::href($pair['srcName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id2']}"); $searchRows[$count]['src_email'] = CRM_Utils_Array::value('src_email', $pairInfo); $searchRows[$count]['src_street'] = CRM_Utils_Array::value('src_street', $pairInfo); $searchRows[$count]['src_postcode'] = CRM_Utils_Array::value('src_postcode', $pairInfo); $searchRows[$count]['dst_image'] = $dstTypeImage; - $searchRows[$count]['dst'] = CRM_Utils_System::href($pair['dstName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id2']}"); + $searchRows[$count]['dst'] = CRM_Utils_System::href($pair['dstName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id1']}"); $searchRows[$count]['dst_email'] = CRM_Utils_Array::value('dst_email', $pairInfo); $searchRows[$count]['dst_street'] = CRM_Utils_Array::value('dst_street', $pairInfo); $searchRows[$count]['dst_postcode'] = CRM_Utils_Array::value('dst_postcode', $pairInfo); diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php index 8eb32921aa..c922d70095 100644 --- a/CRM/Core/BAO/PrevNextCache.php +++ b/CRM/Core/BAO/PrevNextCache.php @@ -591,8 +591,8 @@ WHERE cacheKey LIKE %1 $data['dst' . $key] = $originalData['src' . $key]; } $dao->data = serialize($data); - $dao->entity_id1 = $data['srcID']; - $dao->entity_id2 = $data['dstID']; + $dao->entity_id1 = $data['dstID']; + $dao->entity_id2 = $data['srcID']; $dao->save(); } } diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index e41e73955a..60f555241d 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -389,10 +389,10 @@ class CRM_Dedupe_Finder { } $mainContacts[] = $row = array( - 'srcID' => $srcID, - 'srcName' => $displayNames[$srcID], 'dstID' => $dstID, 'dstName' => $displayNames[$dstID], + 'srcID' => $srcID, + 'srcName' => $displayNames[$srcID], 'weight' => $dupes[2], 'canMerge' => TRUE, ); diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index fb6a4eee8b..82d2a4b55a 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -755,12 +755,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m CRM_Utils_Hook::merge('flip', $dupes, $dupes['dstID'], $dupes['srcID']); $mainId = $dupes['dstID']; $otherId = $dupes['srcID']; - $isAutoFlip = CRM_Utils_Array::value('auto_flip', $dupes, $autoFlip); - // if we can, make sure that $mainId is the one with lower id number - if ($isAutoFlip && ($mainId > $otherId)) { - $mainId = $dupes['srcID']; - $otherId = $dupes['dstID']; - } + if (!$mainId || !$otherId) { // return error return FALSE;