Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 | 2 | /* |
bc77d7c0 TO |
3 | +--------------------------------------------------------------------+ |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
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 | +--------------------------------------------------------------------+ | |
e70a7fc0 | 10 | */ |
6a488035 | 11 | |
50bfb460 SB |
12 | /** |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
50bfb460 SB |
16 | */ |
17 | ||
6a488035 TO |
18 | /* |
19 | * These functions have been deprecated out of API v3 Utils folder as they are not part of the | |
20 | * API. Calling API functions directly is not supported & these functions are not called by any | |
21 | * part of the API so are not really part of the api | |
22 | * | |
23 | */ | |
24 | ||
6a488035 TO |
25 | require_once 'api/v3/utils.php'; |
26 | ||
6a488035 TO |
27 | /** |
28 | * | |
72b3a70c | 29 | * @param array $params |
6a488035 | 30 | * |
a6c01b45 | 31 | * @return array |
353ffa53 | 32 | * <type> |
6a488035 TO |
33 | */ |
34 | function _civicrm_api3_deprecated_duplicate_formatted_contact($params) { | |
9c1bc317 CW |
35 | $id = $params['id'] ?? NULL; |
36 | $externalId = $params['external_identifier'] ?? NULL; | |
6a488035 TO |
37 | if ($id || $externalId) { |
38 | $contact = new CRM_Contact_DAO_Contact(); | |
39 | ||
40 | $contact->id = $id; | |
41 | $contact->external_identifier = $externalId; | |
42 | ||
43 | if ($contact->find(TRUE)) { | |
44 | if ($params['contact_type'] != $contact->contact_type) { | |
972906b3 | 45 | return ['is_error' => 1, 'error_message' => 'Mismatched contact IDs OR Mismatched contact Types']; |
6a488035 | 46 | } |
972906b3 EM |
47 | return [ |
48 | 'is_error' => 1, | |
49 | 'error_message' => [ | |
50 | 'code' => CRM_Core_Error::DUPLICATE_CONTACT, | |
51 | 'params' => $contact->id, | |
52 | 'level' => 'Fatal', | |
53 | 'message' => "Found matching contacts: $contact->id", | |
54 | ], | |
55 | ]; | |
6a488035 TO |
56 | } |
57 | } | |
58 | else { | |
03b40a7b | 59 | $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $params['contact_type'], 'Unsupervised'); |
6a488035 TO |
60 | |
61 | if (!empty($ids)) { | |
972906b3 EM |
62 | return [ |
63 | 'is_error' => 1, | |
64 | 'error_message' => [ | |
65 | 'code' => CRM_Core_Error::DUPLICATE_CONTACT, | |
66 | 'params' => $ids, | |
67 | 'level' => 'Fatal', | |
68 | 'message' => 'Found matching contacts: ' . implode(',', $ids), | |
69 | ], | |
70 | ]; | |
6a488035 TO |
71 | } |
72 | } | |
972906b3 | 73 | return ['is_error' => 0]; |
6a488035 | 74 | } |