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 LocationType records. |
6a488035 TO |
14 | * |
15 | * @package CiviCRM_APIv3 | |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
244bbdd8 | 19 | * Add a LocationType. |
6a488035 | 20 | * |
c490a46a | 21 | * @param array $params |
77b97be7 | 22 | * |
a6c01b45 | 23 | * @return array |
1747ab99 | 24 | * API result array. |
6a488035 | 25 | */ |
6a488035 TO |
26 | function civicrm_api3_location_type_create($params) { |
27 | //set display_name equal to name if it's not defined | |
28 | if (!array_key_exists('display_name', $params) && array_key_exists('name', $params)) { | |
29 | $params['display_name'] = $params['name']; | |
30 | } | |
31 | ||
a25b46e9 | 32 | return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'LocationType'); |
6a488035 TO |
33 | } |
34 | ||
11e09c59 | 35 | /** |
0aa0303c EM |
36 | * Adjust Metadata for Create action. |
37 | * | |
38 | * The metadata is used for setting defaults, documentation & validation. | |
6a488035 | 39 | * |
cf470720 | 40 | * @param array $params |
b081365f | 41 | * Array of parameters determined by getfields. |
6a488035 | 42 | */ |
6a488035 TO |
43 | function _civicrm_api3_location_type_create_spec(&$params) { |
44 | $params['is_active']['api.default'] = 1; | |
45 | $params['name']['api.required'] = 1; | |
46 | } | |
47 | ||
48 | /** | |
244bbdd8 | 49 | * Deletes an existing LocationType. |
6a488035 | 50 | * |
cf470720 | 51 | * @param array $params |
6a488035 | 52 | * |
a6c01b45 | 53 | * @return array |
1747ab99 | 54 | * API result array. |
6a488035 | 55 | */ |
6a488035 TO |
56 | function civicrm_api3_location_type_delete($params) { |
57 | return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
58 | } | |
59 | ||
60 | /** | |
244bbdd8 | 61 | * Retrieve one or more LocationTypes. |
6a488035 | 62 | * |
cf470720 TO |
63 | * @param array $params |
64 | * An associative array of name/value pairs. | |
6a488035 | 65 | * |
a6c01b45 | 66 | * @return array |
1747ab99 | 67 | * API result array. |
6a488035 | 68 | */ |
6a488035 | 69 | function civicrm_api3_location_type_get($params) { |
6a488035 TO |
70 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
71 | } |