diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php
index 82b605a4989f..555f42a4e9fe 100644
--- a/CRM/Contact/Page/AJAX.php
+++ b/CRM/Contact/Page/AJAX.php
@@ -959,25 +959,39 @@ static function selectUnselectContacts() {
static function toggleDedupeSelect() {
$rgid = CRM_Utils_Type::escape($_REQUEST['rgid'], 'Integer');
$gid = CRM_Utils_Type::escape($_REQUEST['gid'], 'Integer');
- $pnid = CRM_Utils_Type::escape($_REQUEST['pnid'], 'Integer');
+ $pnid = $_REQUEST['pnid'];
$isSelected = CRM_Utils_Type::escape($_REQUEST['is_selected'], 'Boolean');
$contactType = CRM_Core_DAO::getFieldValue('CRM_Dedupe_DAO_RuleGroup', $rgid, 'contact_type');
$cacheKeyString = "merge $contactType";
$cacheKeyString .= $rgid ? "_{$rgid}" : '_0';
$cacheKeyString .= $gid ? "_{$gid}" : '_0';
-
- $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE id = %2 AND cacheKey LIKE %3";
+
+
$params = array(
1 => array($isSelected, 'Boolean'),
- 2 => array($pnid, 'Integer'),
3 => array("$cacheKeyString%", 'String') // using % to address rows with conflicts as well
);
+
+ //check pnid is_array or integer
+ $whereClause = NULL;
+ if (is_array($pnid) && !CRM_Utils_Array::crmIsEmptyArray($pnid)) {
+ $pnid = implode(', ', $pnid);
+ $pnid = CRM_Utils_Type::escape($pnid, 'String');
+ $whereClause = " id IN ( {$pnid} ) ";
+ }
+ else {
+ $pnid = CRM_Utils_Type::escape($pnid, 'Integer');
+ $whereClause = " id = %2";
+ $params[2] = array($pnid, 'Integer');
+ }
+
+ $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE {$whereClause} AND cacheKey LIKE %3";
CRM_Core_DAO::executeQuery($sql, $params);
CRM_Utils_System::civiExit();
}
-
+
/**
* @param $name
*
diff --git a/CRM/Core/xml/Menu/Contact.xml b/CRM/Core/xml/Menu/Contact.xml
index 2196378239a3..cde8148ce1de 100644
--- a/CRM/Core/xml/Menu/Contact.xml
+++ b/CRM/Core/xml/Menu/Contact.xml
@@ -393,7 +393,7 @@
-
civicrm/ajax/toggleDedupeSelect
CRM_Contact_Page_AJAX::toggleDedupeSelect
- access CiviCRM
+ merge duplicate contacts
-
civicrm/activity/sms/add
diff --git a/templates/CRM/Contact/Page/DedupeFind.tpl b/templates/CRM/Contact/Page/DedupeFind.tpl
index c5602a4abca4..fd1a84e607f3 100644
--- a/templates/CRM/Contact/Page/DedupeFind.tpl
+++ b/templates/CRM/Contact/Page/DedupeFind.tpl
@@ -84,7 +84,7 @@