Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-03-02-21-30-06
[civicrm-core.git] / CRM / Dedupe / Merger.php
index 1e208b170ebfbaaa1d1f51bc1fe6abb6c6bef431..5bb0785828a00e2e8c81227c2a2d5e4a465e8eeb 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -156,7 +156,7 @@ class CRM_Dedupe_Merger {
   }
 
   /**
-   * Returns the related tables groups for which a contact has any info entered
+   * Returns the related tables groups for which a contact has any info entered.
    */
   public static function getActiveRelTables($cid) {
     $cid = (int) $cid;
@@ -243,7 +243,7 @@ WHERE
   }
 
   /**
-   * Return tables using locations
+   * Return tables using locations.
    */
   public static function locTables() {
     static $locTables;
@@ -563,7 +563,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 bool $autoFlipWether to let api decide which contact to retain and which to delete.
+   * @param bool $autoFlip 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
    *
@@ -608,7 +608,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 bool $autoFlipWether to let api decide which contact to retain and which to delete.
+   * @param bool $autoFlip 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.
    *
    *
@@ -645,7 +645,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
         // Generate var $migrationInfo. The variable structure is exactly same as
         // $formValues submitted during a UI merge for a pair of contacts.
-        $rowsElementsAndInfo = &CRM_Dedupe_Merger::getRowsElementsAndInfo($mainId, $otherId);
+        $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($mainId, $otherId);
 
         $migrationInfo = &$rowsElementsAndInfo['migration_info'];
 
@@ -658,10 +658,10 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         // go ahead with merge if there is no conflict
         if (!CRM_Dedupe_Merger::skipMerge($mainId, $otherId, $migrationInfo, $mode)) {
           CRM_Dedupe_Merger::moveAllBelongings($mainId, $otherId, $migrationInfo);
-          $resultStats['merged'][] = array('main_d' => $mainId, 'other_id' => $otherId);
+          $resultStats['merged'][] = array('main_id' => $mainId, 'other_id' => $otherId);
         }
         else {
-          $resultStats['skipped'][] = array('main_d' => $mainId, 'other_id' => $otherId);
+          $resultStats['skipped'][] = array('main_id' => $mainId, 'other_id' => $otherId);
         }
 
         // delete entry from PrevNextCache table so we don't consider the pair next time
@@ -746,15 +746,13 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         // Rule: resolve address conflict if any -
         if ($fieldName == 'address') {
           $mainNewLocTypeId = $migrationInfo['location'][$fieldName][$fieldCount]['locTypeId'];
-          if (!empty($migrationInfo['main_loc_address']) &&
-            array_key_exists("main_{$mainNewLocTypeId}", $migrationInfo['main_loc_address'])
-          ) {
+          if (!empty($migrationInfo['main_loc_block']) &&
+              array_key_exists("main_address{$mainNewLocTypeId}", $migrationInfo['main_loc_block'])) {
             // main loc already has some address for the loc-type. Its a overwrite situation.
-
             // look for next available loc-type
             $newTypeId = NULL;
             foreach ($allLocationTypes as $typeId => $typeLabel) {
-              if (!array_key_exists("main_{$typeId}", $migrationInfo['main_loc_address'])) {
+              if (!array_key_exists("main_address{$typeId}", $migrationInfo['main_loc_block'])) {
                 $newTypeId = $typeId;
               }
             }
@@ -823,7 +821,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       $params = array(
         'contact_id' => $cid,
         'version' => 3,
-        'return' => array_merge(array('display_name'), self::getContactFields())
+        'return' => array_merge(array('display_name'), self::getContactFields()),
       );
       $result = civicrm_api('contact', 'get', $params);
 
@@ -855,11 +853,10 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         $specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
       }
       $names = array(
-        'preferred_communication_method' =>
-          array(
-            'newName' => 'preferred_communication_method_display',
-            'groupName' => 'preferred_communication_method',
-          ),
+        'preferred_communication_method' => array(
+          'newName' => 'preferred_communication_method_display',
+          'groupName' => 'preferred_communication_method',
+        ),
       );
       CRM_Core_OptionGroup::lookupValues($specialValues[$moniker], $names);
 
@@ -1430,7 +1427,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
                 if (in_array($htmlType, array(
                   'CheckBox',
                   'Multi-Select',
-                  'AdvMulti-Select'
+                  'AdvMulti-Select',
                 ))) {
                   $submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
                       $mergeValue
@@ -1443,7 +1440,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
             }
             elseif (in_array($htmlType, array(
               'Multi-Select Country',
-              'Multi-Select State/Province'
+              'Multi-Select State/Province',
             ))) {
               //we require submitted values should be in array format
               if ($value) {
@@ -1617,7 +1614,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       'modified_date',
       'primary_contact_id',
       'sort_name',
-      'user_unique_id'
+      'user_unique_id',
     );
     foreach ($contactFields as $field => $value) {
       if (in_array($field, $invalidFields)) {
@@ -1629,10 +1626,10 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
   /**
    * Added for CRM-12695
-   * Based on the contactId provided
+   * Based on the contactID provided
    * add/update membership(s) to related contacts
    *
-   * @param contactId
+   * @param int $contactID
    */
   public static function addMembershipToRealtedContacts($contactID) {
     $dao = new CRM_Member_DAO_Membership();
@@ -1659,4 +1656,5 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       } // end of if relationshipTypeId
     }
   }
+
 }