| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 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 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * This api exposes CiviCRM tags. |
| 14 | * |
| 15 | * Tags are used to classify CRM entities (including Contacts, Groups and Actions). |
| 16 | * |
| 17 | * @note this api is for working with tags themselves. To add/remove tags from |
| 18 | * a contact or other entity, use the EntityTag api. |
| 19 | * |
| 20 | * @package CiviCRM_APIv3 |
| 21 | */ |
| 22 | |
| 23 | /** |
| 24 | * Create or update a tag. |
| 25 | * |
| 26 | * Tags are used to classify CRM entities (including Contacts, Groups and Actions). |
| 27 | * |
| 28 | * @param array $params |
| 29 | * Array per getfields metadata. |
| 30 | * |
| 31 | * @return array |
| 32 | * API result array |
| 33 | */ |
| 34 | function civicrm_api3_tag_create($params) { |
| 35 | return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Tag'); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Specify Meta data for create. |
| 40 | * |
| 41 | * Note that this data is retrievable via the getfields function |
| 42 | * and is used for pre-filling defaults and ensuring mandatory requirements are met. |
| 43 | * |
| 44 | * @param array $params |
| 45 | */ |
| 46 | function _civicrm_api3_tag_create_spec(&$params) { |
| 47 | $params['used_for']['api.default'] = 'civicrm_contact'; |
| 48 | $params['name']['api.required'] = 1; |
| 49 | $params['id']['api.aliases'] = ['tag']; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Delete an existing Tag. |
| 54 | * |
| 55 | * @param array $params |
| 56 | * |
| 57 | * @return array |
| 58 | * API result array |
| 59 | */ |
| 60 | function civicrm_api3_tag_delete($params) { |
| 61 | return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get a Tag. |
| 66 | * |
| 67 | * This api is used for finding an existing tag. |
| 68 | * Either id or name of tag are required parameters for this api. |
| 69 | * |
| 70 | * @param array $params |
| 71 | * Array per getfields metadata. |
| 72 | * |
| 73 | * @return array |
| 74 | * API result array |
| 75 | */ |
| 76 | function civicrm_api3_tag_get($params) { |
| 77 | |
| 78 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); |
| 79 | } |