3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
13 * This api exposes CiviCRM contact types and sub-types.
15 * CiviCRM comes with 3 primary contact types - Individual, Organization & Household.
16 * Changing these is not advised, but sub_types can be created with this api.
17 * Pass 'parent_id' param to specify which base type a new sub_type extends.
19 * @package CiviCRM_APIv3
23 * Create/update ContactType.
25 * This API is used to create new ContactType or update any of the existing
26 * In case of updating existing ContactType, id of that particular ContactType must
27 * be in $params array.
29 * @param array $params
30 * Array per getfields metadata.
35 function civicrm_api3_contact_type_create($params) {
36 civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__
), ['name', 'parent_id']);
38 if (empty($params['id'])) {
39 if (!array_key_exists('label', $params)) {
40 $params['label'] = $params['name'];
42 if (!array_key_exists('is_active', $params)) {
43 $params['is_active'] = TRUE;
45 $params['name'] = CRM_Utils_String
::munge($params['name']);
48 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'ContactType');
52 * Returns array of contact_types matching a set of one or more properties.
54 * @param array $params
55 * One or more valid property_name=>value pairs.
56 * If $params is set as null, all contact_types will be returned
59 * Array of matching contact_types
61 function civicrm_api3_contact_type_get($params) {
62 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
66 * Delete an existing ContactType.
68 * This method is used to delete any existing ContactType given its id.
70 * @param array $params
76 function civicrm_api3_contact_type_delete($params) {
77 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);