Code styling fixes
[civicrm-core.git] / CRM / Contact / Page / DedupeFind.php
index 22e5100ce2f5c2629e6dcf9346e6aa2a64de015d..0129be19d57f0ebbf402f033db28ab20e5c030fc 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -39,7 +39,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   protected $_gid;
 
   /**
-   * Get BAO Name
+   * Get BAO Name.
    *
    * @return string
    *   Classname of BAO.
@@ -49,7 +49,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   }
 
   /**
-   * Get action Links
+   * Get action Links.
    *
    * @return void
    *   (reference) of action links
@@ -58,7 +58,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   }
 
   /**
-   * Browse all rule groups
+   * Browse all rule groups.
    *
    * @return void
    */
@@ -94,7 +94,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
     elseif ($action & CRM_Core_Action::MAP) {
       // do a batch merge if requested
       $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
-      $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', TRUE, TRUE);
+      $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', TRUE, 75);
 
       $skippedCount = CRM_Utils_Request::retrieve('skipped', 'Positive', $this, FALSE, 0);
       $skippedCount = $skippedCount + count($result['skipped']);
@@ -157,6 +157,9 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
       if ($rgid) {
         $sourceParams .= "&rgid={$rgid}";
       }
+      if ($context == 'conflicts') {
+        $sourceParams .= "&selected=1";
+      }
 
       $this->assign('sourceUrl', CRM_Utils_System::url('civicrm/ajax/dedupefind', $sourceParams, FALSE, NULL, FALSE));
 
@@ -165,11 +168,31 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
       $cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
       $cacheKeyString .= $gid ? "_{$gid}" : '_0';
 
+      $stats = CRM_Dedupe_Merger::getMergeStatsMsg($cacheKeyString);
+      if ($stats) {
+        CRM_Core_Session::setStatus($stats);
+        // reset so we not displaying same message again
+        CRM_Dedupe_Merger::resetMergeStats($cacheKeyString);
+      }
       $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND
                                                                  pn.entity_id2 = de.contact_id2 )";
       $where = "de.id IS NULL";
+      if ($context == 'conflicts') {
+        $where .= " AND pn.is_selected = 1";
+      }
       $this->_mainContacts = CRM_Core_BAO_PrevNextCache::retrieve($cacheKeyString, $join, $where);
       if (empty($this->_mainContacts)) {
+        if ($context == 'conflicts') {
+          // if the current screen was intended to list only selected contacts, move back to full dupe list
+          $sourceParams = 'reset=1&action=update';
+          if ($gid) {
+            $sourceParams .= "&gid={$gid}";
+          }
+          if ($rgid) {
+            $sourceParams .= "&rgid={$rgid}";
+          }
+          CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $sourceParams));
+        }
         if ($gid) {
           $foundDupes = $this->get("dedupe_dupes_$gid");
           if (!$foundDupes) {
@@ -314,7 +337,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   }
 
   /**
-   * Browse all rule groups
+   * Browse all rule groups.
    *
    * @return void
    */
@@ -331,7 +354,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   }
 
   /**
-   * Get name of edit form
+   * Get name of edit form.
    *
    * @return string
    *   classname of edit form
@@ -341,7 +364,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   }
 
   /**
-   * Get edit form name
+   * Get edit form name.
    *
    * @return string
    *   name of this page
@@ -351,7 +374,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
   }
 
   /**
-   * Get user context
+   * Get user context.
    *
    * @param null $mode
    *