Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
244bbdd8 | 29 | * The ActivityType api is deprecated. Please use the OptionValue api instead. |
c28e1768 | 30 | * |
a14e9d08 | 31 | * @deprecated |
6a488035 TO |
32 | * |
33 | * @package CiviCRM_APIv3 | |
6a488035 TO |
34 | */ |
35 | ||
a14e9d08 | 36 | /** |
9d32e6f7 EM |
37 | * Notification of deprecated function. |
38 | * | |
a14e9d08 | 39 | * @deprecated api notice |
a6c01b45 | 40 | * @return string |
72b3a70c | 41 | * to indicate this entire api entity is deprecated |
a14e9d08 CW |
42 | */ |
43 | function _civicrm_api3_activity_type_deprecation() { | |
244bbdd8 | 44 | return 'The ActivityType api is deprecated. Please use the OptionValue api instead.'; |
a14e9d08 CW |
45 | } |
46 | ||
6a488035 | 47 | /** |
9d32e6f7 | 48 | * Retrieve activity types. |
6a488035 | 49 | * |
c490a46a | 50 | * @param array $params |
77b97be7 | 51 | * |
a6c01b45 | 52 | * @return array |
72b3a70c | 53 | * activity types keyed by id |
244bbdd8 | 54 | * @deprecated - use the getoptions action instead |
6a488035 TO |
55 | */ |
56 | function civicrm_api3_activity_type_get($params) { | |
57 | ||
6a488035 TO |
58 | $activityTypes = CRM_Core_OptionGroup::values('activity_type'); |
59 | return civicrm_api3_create_success($activityTypes, $params, 'activity_type', 'get'); | |
60 | } | |
61 | ||
62 | /** | |
9d32e6f7 | 63 | * Create activity type. |
6a488035 | 64 | * |
cf470720 | 65 | * @param array $params |
6a488035 | 66 | * |
a6c01b45 | 67 | * @return array |
72b3a70c | 68 | * created / updated activity type |
6a488035 | 69 | * |
244bbdd8 | 70 | * @deprecated use the OptionValue api instead |
6a488035 TO |
71 | */ |
72 | function civicrm_api3_activity_type_create($params) { | |
73 | ||
6a488035 | 74 | $action = 1; |
6a488035 TO |
75 | |
76 | if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) { | |
77 | $action = 2; | |
78 | } | |
79 | ||
ff625280 | 80 | $activityObject = CRM_Core_OptionValue::addOptionValue($params, 'activity_type', $action, $optionValueID); |
cf8f0fff | 81 | $activityType = []; |
6a488035 TO |
82 | _civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]); |
83 | return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create'); | |
84 | } | |
11e09c59 TO |
85 | |
86 | /** | |
0aa0303c EM |
87 | * Adjust Metadata for Create action. |
88 | * | |
89 | * The metadata is used for setting defaults, documentation & validation. | |
1c88e578 | 90 | * |
cf470720 | 91 | * @param array $params |
b081365f | 92 | * Array of parameters determined by getfields. |
6a488035 TO |
93 | */ |
94 | function _civicrm_api3_activity_type_create_spec(&$params) { | |
cf8f0fff | 95 | $params['label'] = [ |
d142432b EM |
96 | 'api.required' => 1, |
97 | 'title' => 'Label', | |
98 | 'type' => CRM_Utils_Type::T_STRING, | |
cf8f0fff CW |
99 | ]; |
100 | $params['weight'] = [ | |
d142432b EM |
101 | 'api.required' => 1, |
102 | 'title' => 'Weight', | |
103 | 'type' => CRM_Utils_Type::T_STRING, | |
cf8f0fff | 104 | ]; |
6a488035 TO |
105 | } |
106 | ||
107 | /** | |
244bbdd8 | 108 | * Delete ActivityType. |
6a488035 | 109 | * |
cf470720 TO |
110 | * @param array $params |
111 | * Array including id of activity_type to delete. | |
8089541a | 112 | * @return array API result array |
8089541a | 113 | * @throws API_Exception |
244bbdd8 | 114 | * @deprecated use OptionValue api |
6a488035 TO |
115 | */ |
116 | function civicrm_api3_activity_type_delete($params) { | |
a60c0bc8 SL |
117 | $result = CRM_Core_BAO_OptionValue::del($params['id']); |
118 | if ($result) { | |
119 | return civicrm_api3_create_success(TRUE, $params); | |
120 | } | |
121 | throw new API_Exception("Failure to delete activity type id {$params['id']}"); | |
6a488035 | 122 | } |