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_DedupeException
extends CRM_Dedupe_DAO_DedupeException
{
24 * Create a dedupe exception record.
26 * @param array $params
28 * @return \CRM_Dedupe_DAO_DedupeException
30 public static function create($params) {
31 $hook = empty($params['id']) ?
'create' : 'edit';
32 CRM_Utils_Hook
::pre($hook, 'DedupeException', $params['id'] ??
NULL, $params);
33 // Also call hook with deprecated entity name
34 CRM_Utils_Hook
::pre($hook, 'Exception', $params['id'] ??
NULL, $params);
35 $contact1 = $params['contact_id1'] ??
NULL;
36 $contact2 = $params['contact_id2'] ??
NULL;
37 $dao = new CRM_Dedupe_BAO_DedupeException();
38 $dao->copyValues($params);
39 if ($contact1 && $contact2) {
40 CRM_Core_DAO
::singleValueQuery("
41 DELETE FROM civicrm_prevnext_cache
42 WHERE (entity_id1 = %1 AND entity_id2 = %2)
43 OR (entity_id1 = %2 AND entity_id2 = %2)",
44 [1 => [$contact1, 'Integer'], 2 => [$contact2, 'Integer']]
46 if ($contact2 < $contact1) {
47 // These are expected to be saved lowest first.
48 $dao->contact_id1
= $contact2;
49 $dao->contact_id2
= $contact1;
53 CRM_Utils_Hook
::post($hook, 'DedupeException', $dao->id
, $dao);
54 // Also call hook with deprecated entity name
55 CRM_Utils_Hook
::post($hook, 'Exception', $dao->id
, $dao);