INFRA-132 - Copyright header - Drupal.WhiteSpace.ScopeIndent.IncorrectExact
[civicrm-core.git] / api / v3 / ActivityType.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * @deprecated
30 *
31 * @package CiviCRM_APIv3
32 * @subpackage API_Activity
33 *
34 * @copyright CiviCRM LLC (c) 2004-2014
35 * $Id: ActivityType.php 30171 2010-10-14 09:11:27Z mover $
36 *
37 */
38
39 /**
40 * @deprecated api notice
41 * @return string
42 * to indicate this entire api entity is deprecated
43 */
44 function _civicrm_api3_activity_type_deprecation() {
45 return 'The activity_type api is deprecated. Please use the option_value api instead.';
46 }
47
48 /**
49 * retrieve activity types
50 *
51 * @param array $params
52 *
53 * @return array
54 * activity types keyed by id
55 * @deprecated - use getoptions
56 */
57 function civicrm_api3_activity_type_get($params) {
58
59 $activityTypes = CRM_Core_OptionGroup::values('activity_type');
60 return civicrm_api3_create_success($activityTypes, $params, 'activity_type', 'get');
61 }
62
63 /**
64 * create activity type (
65 *
66 * @param array $params
67 *
68 * @return array
69 * created / updated activity type
70 *
71 * @deprecated - use option_value create
72 */
73 function civicrm_api3_activity_type_create($params) {
74
75 $action = 1;
76 $groupParams = array('name' => 'activity_type');
77
78 if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) {
79 $action = 2;
80 }
81
82 $activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID);
83 $activityType = array();
84 _civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]);
85 return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create');
86 }
87
88 /**
89 * Adjust Metadata for Create action
90 *
91 * The metadata is used for setting defaults, documentation & validation
92 * @param array $params
93 * Array or parameters determined by getfields.
94 */
95 function _civicrm_api3_activity_type_create_spec(&$params) {
96 $params['label']['api.required'] = 1;
97 $params['label']['title'] = 'Label';
98 $params['weight']['api.required'] = 1;
99 $params['weight']['title'] = 'Weight';
100 }
101
102 /**
103 * delete activity type
104 *
105 * @param array $params
106 * Array including id of activity_type to delete.
107
108 * @return array
109 * API result array
110 *
111 * @deprecated - we will introduce OptionValue Delete- plse consider helping with this if not done
112 */
113 function civicrm_api3_activity_type_delete($params) {
114 return civicrm_api3_create_success(CRM_Core_BAO_OptionValue::del($params['id']), $params);
115 }