+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
protected $_gid;
/**
- * Get BAO Name
+ * Get BAO Name.
*
- * @return string Classname of BAO.
+ * @return string
+ * Classname of BAO.
*/
- function getBAOName() {
+ public function getBAOName() {
return 'CRM_Dedupe_BAO_RuleGroup';
}
/**
- * Get action Links
+ * Get action Links.
*
- * @return array (reference) of action links
+ * @return void
+ * (reference) of action links
*/
- function &links() {}
+ public function &links() {
+ }
/**
- * Browse all rule groups
+ * Browse all rule groups.
*
* @return void
- * @access public
*/
- function run() {
- $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
- $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
+ public function run() {
+ $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
+ $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$session = CRM_Core_Session::singleton();
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']);
- $mergedCount = CRM_Utils_Request::retrieve('merged', 'Positive', $this, FALSE, 0);
- $mergedCount = $mergedCount + count($result['merged']);
+ $mergedCount = CRM_Utils_Request::retrieve('merged', 'Positive', $this, FALSE, 0);
+ $mergedCount = $mergedCount + count($result['merged']);
if (empty($result['merged']) && empty($result['skipped'])) {
$message = '';
if ($action & CRM_Core_Action::UPDATE ||
$action & CRM_Core_Action::BROWSE
) {
- $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
- $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
+ $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
+ $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
$this->action = CRM_Core_Action::UPDATE;
//calculate the $contactType
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));
$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) {
$cids[$dupe[1]] = 1;
}
$cidString = implode(', ', array_keys($cids));
- $sql = "SELECT id, display_name FROM civicrm_contact WHERE id IN ($cidString) ORDER BY sort_name";
- $dao = new CRM_Core_DAO();
+ $sql = "SELECT id, display_name FROM civicrm_contact WHERE id IN ($cidString) ORDER BY sort_name";
+ $dao = new CRM_Core_DAO();
$dao->query($sql);
$displayNames = array();
while ($dao->fetch()) {
// (also, consider sorting by dupe count first)
// lobo - change the sort to by threshold value
// so the more likely dupes are sorted first
- $session = CRM_Core_Session::singleton();
- $userId = $session->get('userID');
+ $session = CRM_Core_Session::singleton();
+ $userId = $session->get('userID');
$mainContacts = $permission = array();
foreach ($foundDupes as $dupes) {
* Eliminate this since it introduces 3 queries PER merge row
* and hence is very expensive
* CRM-8822
- if ( !array_key_exists( $srcID, $permission ) ) {
- $permission[$srcID] = CRM_Contact_BAO_Contact_Permission::allow( $srcID, CRM_Core_Permission::EDIT );
- }
- if ( !array_key_exists( $dstID, $permission ) ) {
- $permission[$dstID] = CRM_Contact_BAO_Contact_Permission::allow( $dstID, CRM_Core_Permission::EDIT );
- }
-
- $canMerge = ( $permission[$dstID] && $permission[$srcID] );
+ * if ( !array_key_exists( $srcID, $permission ) ) {
+ * $permission[$srcID] = CRM_Contact_BAO_Contact_Permission::allow( $srcID, CRM_Core_Permission::EDIT );
+ * }
+ * if ( !array_key_exists( $dstID, $permission ) ) {
+ * $permission[$dstID] = CRM_Contact_BAO_Contact_Permission::allow( $dstID, CRM_Core_Permission::EDIT );
+ * }
+ *
+ * $canMerge = ( $permission[$dstID] && $permission[$srcID] );
*
*/
$session = CRM_Core_Session::singleton();
if ($this->_cid) {
$session->pushUserContext(CRM_Utils_System::url('civicrm/contact/deduperules',
- "action=update&rgid={$this->_rgid}&gid={$this->_gid}&cid={$this->_cid}"
- ));
+ "action=update&rgid={$this->_rgid}&gid={$this->_gid}&cid={$this->_cid}"
+ ));
}
else {
$session->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind',
- "reset=1&action=update&rgid={$this->_rgid}"
- ));
+ "reset=1&action=update&rgid={$this->_rgid}"
+ ));
}
}
}
}
/**
- * Browse all rule groups
+ * Browse all rule groups.
*
* @return void
- * @access public
*/
- function browse() {
+ public function browse() {
$this->assign('main_contacts', $this->_mainContacts);
if ($this->_cid) {
}
/**
- * Get name of edit form
+ * Get name of edit form.
*
- * @return string classname of edit form
+ * @return string
+ * classname of edit form
*/
- function editForm() {
+ public function editForm() {
return 'CRM_Contact_Form_DedupeFind';
}
/**
- * Get edit form name
+ * Get edit form name.
*
- * @return string name of this page
+ * @return string
+ * name of this page
*/
- function editName() {
+ public function editName() {
return 'DedupeFind';
}
/**
- * Get user context
+ * Get user context.
*
* @param null $mode
*
- * @return string user context
+ * @return string
+ * user context
*/
- function userContext($mode = NULL) {
+ public function userContext($mode = NULL) {
return 'civicrm/contact/dedupefind';
}
-}
+}