CRM-19035 fix UI to be consistent in dstID & srcID handling.
authoreileen <emcnaughton@wikimedia.org>
Tue, 12 Jul 2016 05:01:04 +0000 (17:01 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 12 Jul 2016 05:31:38 +0000 (17:31 +1200)
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

CRM/Contact/Page/AJAX.php
CRM/Core/BAO/PrevNextCache.php
CRM/Dedupe/Finder.php
CRM/Dedupe/Merger.php

index 2da17695ead4a14f2a754689d2e2c06307680490..4c1e37aa88c47ecaa1edfed8c220af9ace384839 100644 (file)
@@ -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'] = "<input type='checkbox' class='crm-dedupe-select' name='pnid_{$pairInfo['prevnext_id']}' value='{$pairInfo['is_selected']}' onclick='toggleDedupeSelect(this)'>";
       $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);
index 8eb32921aa2dfd49177122c5c748f1cba6219eb7..c922d70095cc9d8cd65cddc5cc7b0e62985c1fed 100644 (file)
@@ -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();
       }
     }
index e41e73955a6e865b0450e64cc5bc039b4ae9d23f..60f555241d9dd78bdece8d1bc3f49c51457b3f8d 100644 (file)
@@ -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,
       );
index fb6a4eee8b0695111121fc2a6139533bc9551c89..82d2a4b55a011f934d35b460be9e04e374c2b01b 100644 (file)
@@ -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;