3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Manages dedupe exceptions - ie pairs marked as non-duplicates.
21 class CRM_Dedupe_BAO_Exception
extends CRM_Dedupe_DAO_Exception
{
24 * Create a dedupe exception record.
26 * @param array $params
28 * @return \CRM_Dedupe_BAO_Exception
30 public static function create($params) {
31 $hook = empty($params['id']) ?
'create' : 'edit';
32 CRM_Utils_Hook
::pre($hook, 'Exception', CRM_Utils_Array
::value('id', $params), $params);
33 $contact1 = $params['contact_id1'] ??
NULL;
34 $contact2 = $params['contact_id2'] ??
NULL;
35 $dao = new CRM_Dedupe_BAO_Exception();
36 $dao->copyValues($params);
37 if ($contact1 && $contact2) {
38 CRM_Core_DAO
::singleValueQuery("
39 DELETE FROM civicrm_prevnext_cache
40 WHERE (entity_id1 = %1 AND entity_id2 = %2)
41 OR (entity_id1 = %2 AND entity_id2 = %2)",
42 [1 => [$contact1, 'Integer'], 2 => [$contact2, 'Integer']]
44 if ($contact2 < $contact1) {
45 // These are expected to be saved lowest first.
46 $dao->contact_id1
= $contact2;
47 $dao->contact_id2
= $contact1;
52 CRM_Utils_Hook
::post($hook, 'Exception', $dao->id
, $dao);