Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
a30c801b | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
244bbdd8 | 13 | * This api exposes CiviCRM email records. |
6a488035 TO |
14 | * |
15 | * @package CiviCRM_APIv3 | |
6a488035 TO |
16 | */ |
17 | ||
6a488035 | 18 | /** |
2e66abf8 | 19 | * Add an Email for a contact. |
6a488035 | 20 | * |
c490a46a | 21 | * @param array $params |
2e66abf8 | 22 | * Array per getfields metadata. |
77b97be7 | 23 | * |
a6c01b45 | 24 | * @return array |
72b3a70c | 25 | * API result array |
6a488035 TO |
26 | */ |
27 | function civicrm_api3_email_create($params) { | |
ddaf2161 | 28 | return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Email'); |
6a488035 | 29 | } |
11e09c59 TO |
30 | |
31 | /** | |
0aa0303c EM |
32 | * Adjust Metadata for Create action. |
33 | * | |
34 | * The metadata is used for setting defaults, documentation & validation. | |
1c88e578 | 35 | * |
cf470720 | 36 | * @param array $params |
b081365f | 37 | * Array of parameters determined by getfields. |
6a488035 TO |
38 | */ |
39 | function _civicrm_api3_email_create_spec(&$params) { | |
40 | // TODO a 'clever' default should be introduced | |
41 | $params['is_primary']['api.default'] = 0; | |
42 | $params['email']['api.required'] = 1; | |
43 | $params['contact_id']['api.required'] = 1; | |
2890c0f9 AS |
44 | $defaultLocation = CRM_Core_BAO_LocationType::getDefault(); |
45 | if ($defaultLocation) { | |
46 | $params['location_type_id']['api.default'] = $defaultLocation->id; | |
47 | } | |
6a488035 TO |
48 | } |
49 | ||
50 | /** | |
2e66abf8 | 51 | * Deletes an existing Email. |
6a488035 | 52 | * |
cf470720 | 53 | * @param array $params |
2e66abf8 | 54 | * Array per getfields metadata. |
6a488035 | 55 | * |
2e66abf8 EM |
56 | * @return array |
57 | * API result array. | |
6a488035 TO |
58 | */ |
59 | function civicrm_api3_email_delete($params) { | |
60 | return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
61 | } | |
62 | ||
63 | /** | |
2e66abf8 | 64 | * Retrieve one or more emails. |
6a488035 | 65 | * |
cf470720 | 66 | * @param array $params |
2e66abf8 | 67 | * Array per getfields metadata. |
6a488035 | 68 | * |
a6c01b45 | 69 | * @return array |
72b3a70c | 70 | * api result array |
6a488035 TO |
71 | */ |
72 | function civicrm_api3_email_get($params) { | |
6a488035 TO |
73 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
74 | } |