/
DeprecatedUtils.php
74 lines (67 loc) · 2.17 KB
/
DeprecatedUtils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
/*
* These functions have been deprecated out of API v3 Utils folder as they are not part of the
* API. Calling API functions directly is not supported & these functions are not called by any
* part of the API so are not really part of the api
*
*/
require_once 'api/v3/utils.php';
/**
*
* @param array $params
*
* @return array
* <type>
*/
function _civicrm_api3_deprecated_duplicate_formatted_contact($params) {
$id = $params['id'] ?? NULL;
$externalId = $params['external_identifier'] ?? NULL;
if ($id || $externalId) {
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $id;
$contact->external_identifier = $externalId;
if ($contact->find(TRUE)) {
if ($params['contact_type'] != $contact->contact_type) {
return ['is_error' => 1, 'error_message' => 'Mismatched contact IDs OR Mismatched contact Types'];
}
return [
'is_error' => 1,
'error_message' => [
'code' => CRM_Core_Error::DUPLICATE_CONTACT,
'params' => $contact->id,
'level' => 'Fatal',
'message' => "Found matching contacts: $contact->id",
],
];
}
}
else {
$ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $params['contact_type'], 'Unsupervised');
if (!empty($ids)) {
return [
'is_error' => 1,
'error_message' => [
'code' => CRM_Core_Error::DUPLICATE_CONTACT,
'params' => $ids,
'level' => 'Fatal',
'message' => 'Found matching contacts: ' . implode(',', $ids),
],
];
}
}
return ['is_error' => 0];
}