Commit | Line | Data |
---|---|---|
2b0e7d03 EM |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
a30c801b | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
2b0e7d03 | 5 | | | |
a30c801b TO |
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 | | |
2b0e7d03 EM |
9 | +--------------------------------------------------------------------+ |
10 | */ | |
11 | ||
12 | /** | |
13 | * This api exposes CiviCRM the user framework user account. | |
14 | * | |
15 | * @package CiviCRM_APIv3 | |
16 | */ | |
17 | ||
18 | /** | |
19 | * Get details about the CMS User entity. | |
20 | * | |
21 | * @param array $params | |
22 | * | |
23 | * @return array | |
24 | */ | |
25 | function civicrm_api3_user_get($params) { | |
26 | if (empty($params['contact_id'])) { | |
cf8f0fff | 27 | $params['contact_id'] = civicrm_api3('UFMatch', 'getvalue', [ |
2b0e7d03 EM |
28 | 'uf_id' => $params['id'], |
29 | 'domain_id' => CRM_Core_Config::domainID(), | |
30 | 'return' => 'contact_id', | |
cf8f0fff | 31 | ]); |
2b0e7d03 EM |
32 | } |
33 | $result = CRM_Core_Config::singleton()->userSystem->getUser($params['contact_id']); | |
34 | $result['contact_id'] = $params['contact_id']; | |
35 | return civicrm_api3_create_success( | |
cf8f0fff | 36 | [$result['id'] => $result], |
2b0e7d03 EM |
37 | $params, |
38 | 'user', | |
39 | 'get' | |
40 | ); | |
41 | ||
42 | } | |
43 | ||
44 | /** | |
45 | * Adjust Metadata for Get action. | |
46 | * | |
47 | * The metadata is used for setting defaults, documentation & validation. | |
48 | * | |
49 | * @param array $params | |
50 | * Array of parameters determined by getfields. | |
51 | */ | |
52 | function _civicrm_api3_user_get_spec(&$params) { | |
53 | // At this stage contact-id is required - we may be able to loosen this. | |
cf8f0fff | 54 | $params['contact_id'] = [ |
2b0e7d03 EM |
55 | 'title' => 'Contact ID', |
56 | 'type' => CRM_Utils_Type::T_INT, | |
57 | 'api.required' => 1, | |
cf8f0fff CW |
58 | ]; |
59 | $params['id'] = [ | |
2b0e7d03 EM |
60 | 'title' => 'CMS User ID', |
61 | 'type' => CRM_Utils_Type::T_INT, | |
cf8f0fff CW |
62 | ]; |
63 | $params['name'] = [ | |
2b0e7d03 EM |
64 | 'title' => 'Username', |
65 | 'type' => CRM_Utils_Type::T_STRING, | |
cf8f0fff | 66 | ]; |
2b0e7d03 | 67 | } |