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 | * The ActivityType api is deprecated. Please use the OptionValue api instead. |
c28e1768 | 14 | * |
a14e9d08 | 15 | * @deprecated |
6a488035 TO |
16 | * |
17 | * @package CiviCRM_APIv3 | |
6a488035 TO |
18 | */ |
19 | ||
a14e9d08 | 20 | /** |
9d32e6f7 EM |
21 | * Notification of deprecated function. |
22 | * | |
a14e9d08 | 23 | * @deprecated api notice |
a6c01b45 | 24 | * @return string |
72b3a70c | 25 | * to indicate this entire api entity is deprecated |
a14e9d08 CW |
26 | */ |
27 | function _civicrm_api3_activity_type_deprecation() { | |
244bbdd8 | 28 | return 'The ActivityType api is deprecated. Please use the OptionValue api instead.'; |
a14e9d08 CW |
29 | } |
30 | ||
6a488035 | 31 | /** |
9d32e6f7 | 32 | * Retrieve activity types. |
6a488035 | 33 | * |
c490a46a | 34 | * @param array $params |
77b97be7 | 35 | * |
a6c01b45 | 36 | * @return array |
72b3a70c | 37 | * activity types keyed by id |
244bbdd8 | 38 | * @deprecated - use the getoptions action instead |
6a488035 TO |
39 | */ |
40 | function civicrm_api3_activity_type_get($params) { | |
41 | ||
6a488035 TO |
42 | $activityTypes = CRM_Core_OptionGroup::values('activity_type'); |
43 | return civicrm_api3_create_success($activityTypes, $params, 'activity_type', 'get'); | |
44 | } | |
45 | ||
46 | /** | |
9d32e6f7 | 47 | * Create activity type. |
6a488035 | 48 | * |
cf470720 | 49 | * @param array $params |
6a488035 | 50 | * |
a6c01b45 | 51 | * @return array |
72b3a70c | 52 | * created / updated activity type |
6a488035 | 53 | * |
244bbdd8 | 54 | * @deprecated use the OptionValue api instead |
6a488035 TO |
55 | */ |
56 | function civicrm_api3_activity_type_create($params) { | |
57 | ||
6a488035 | 58 | $action = 1; |
6a488035 TO |
59 | |
60 | if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) { | |
61 | $action = 2; | |
62 | } | |
63 | ||
ff625280 | 64 | $activityObject = CRM_Core_OptionValue::addOptionValue($params, 'activity_type', $action, $optionValueID); |
cf8f0fff | 65 | $activityType = []; |
6a488035 TO |
66 | _civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]); |
67 | return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create'); | |
68 | } | |
11e09c59 TO |
69 | |
70 | /** | |
0aa0303c EM |
71 | * Adjust Metadata for Create action. |
72 | * | |
73 | * The metadata is used for setting defaults, documentation & validation. | |
1c88e578 | 74 | * |
cf470720 | 75 | * @param array $params |
b081365f | 76 | * Array of parameters determined by getfields. |
6a488035 TO |
77 | */ |
78 | function _civicrm_api3_activity_type_create_spec(&$params) { | |
cf8f0fff | 79 | $params['label'] = [ |
d142432b EM |
80 | 'api.required' => 1, |
81 | 'title' => 'Label', | |
82 | 'type' => CRM_Utils_Type::T_STRING, | |
cf8f0fff CW |
83 | ]; |
84 | $params['weight'] = [ | |
d142432b EM |
85 | 'api.required' => 1, |
86 | 'title' => 'Weight', | |
87 | 'type' => CRM_Utils_Type::T_STRING, | |
cf8f0fff | 88 | ]; |
6a488035 TO |
89 | } |
90 | ||
91 | /** | |
244bbdd8 | 92 | * Delete ActivityType. |
6a488035 | 93 | * |
cf470720 TO |
94 | * @param array $params |
95 | * Array including id of activity_type to delete. | |
8089541a | 96 | * @return array API result array |
8089541a | 97 | * @throws API_Exception |
244bbdd8 | 98 | * @deprecated use OptionValue api |
6a488035 TO |
99 | */ |
100 | function civicrm_api3_activity_type_delete($params) { | |
a60c0bc8 SL |
101 | $result = CRM_Core_BAO_OptionValue::del($params['id']); |
102 | if ($result) { | |
103 | return civicrm_api3_create_success(TRUE, $params); | |
104 | } | |
105 | throw new API_Exception("Failure to delete activity type id {$params['id']}"); | |
6a488035 | 106 | } |