Merge pull request #17376 from artfulrobot/artfulrobot-public-status-messages
[civicrm-core.git] / api / v3 / Tag.php
CommitLineData
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/**
b081365f 13 * This api exposes CiviCRM tags.
6a488035 14 *
b081365f 15 * Tags are used to classify CRM entities (including Contacts, Groups and Actions).
6a488035 16 *
b081365f
CW
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
6a488035
TO
21 */
22
6a488035 23/**
b081365f 24 * Create or update a tag.
2fb1dd66
EM
25 *
26 * Tags are used to classify CRM entities (including Contacts, Groups and Actions).
6a488035 27 *
c490a46a 28 * @param array $params
2e66abf8 29 * Array per getfields metadata.
77b97be7 30 *
a6c01b45 31 * @return array
00f8641b 32 * API result array
6a488035
TO
33 */
34function civicrm_api3_tag_create($params) {
1237d8d7 35 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Tag');
d989d349 36}
11e09c59
TO
37
38/**
2fb1dd66
EM
39 * Specify Meta data for create.
40 *
41 * Note that this data is retrievable via the getfields function
6a488035 42 * and is used for pre-filling defaults and ensuring mandatory requirements are met.
9657ccf2
EM
43 *
44 * @param array $params
6a488035
TO
45 */
46function _civicrm_api3_tag_create_spec(&$params) {
47 $params['used_for']['api.default'] = 'civicrm_contact';
48 $params['name']['api.required'] = 1;
cf8f0fff 49 $params['id']['api.aliases'] = ['tag'];
6a488035
TO
50}
51
52/**
2fb1dd66 53 * Delete an existing Tag.
6a488035 54 *
cf470720 55 * @param array $params
6a488035 56 *
a6c01b45 57 * @return array
72b3a70c 58 * API result array
6a488035
TO
59 */
60function 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 *
cf470720 70 * @param array $params
2e66abf8 71 * Array per getfields metadata.
6a488035 72 *
a6c01b45 73 * @return array
00f8641b 74 * API result array
6a488035
TO
75 */
76function civicrm_api3_tag_get($params) {
77
78 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
79}