Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
5 | | CiviCRM version 4.3 | | |
6 | +--------------------------------------------------------------------+ | |
7 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
8 | +--------------------------------------------------------------------+ | |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * Definition of the ActivityType part of the CRM API. | |
31 | * More detailed documentation can be found | |
32 | * {@link http://objectledge.org/confluence/display/CRM/CRM+v1.0+Public+APIs | |
33 | * here} | |
34 | * | |
35 | * @package CiviCRM_APIv3 | |
36 | * @subpackage API_Activity | |
37 | * | |
38 | * @copyright CiviCRM LLC (c) 2004-2013 | |
39 | * $Id: ActivityType.php 30171 2010-10-14 09:11:27Z mover $ | |
40 | * | |
41 | */ | |
42 | ||
6a488035 TO |
43 | /** |
44 | * Function to retrieve activity types | |
45 | * | |
46 | * @return array $activityTypes activity types keyed by id | |
47 | * @access public | |
48 | * | |
49 | * @example ActivityTypeGet.php | |
50 | * @deprecated - use constant_get | |
51 | */ | |
52 | function civicrm_api3_activity_type_get($params) { | |
53 | ||
54 | ||
55 | $activityTypes = CRM_Core_OptionGroup::values('activity_type'); | |
56 | return civicrm_api3_create_success($activityTypes, $params, 'activity_type', 'get'); | |
57 | } | |
58 | ||
59 | /** | |
60 | * Function to create activity type ( | |
61 | * | |
62 | * @param array $params associated array of fields | |
63 | * $params['option_value_id'] is required for updation of activity type | |
64 | * | |
65 | * @return array $activityType created / updated activity type | |
66 | * | |
67 | * @access public | |
68 | * | |
69 | *{@schema Activity/ActivityType.xml} | |
70 | * | |
71 | * {@example ActivityTypeCreate.php 0} | |
72 | * @deprecated - we will introduce OptionValue Create - plse consider helping with this if not done | |
73 | */ | |
74 | function civicrm_api3_activity_type_create($params) { | |
75 | ||
76 | ||
77 | $action = 1; | |
78 | $groupParams = array('name' => 'activity_type'); | |
79 | ||
80 | if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) { | |
81 | $action = 2; | |
82 | } | |
83 | ||
6a488035 TO |
84 | $activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID); |
85 | $activityType = array(); | |
86 | _civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]); | |
87 | return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create'); | |
88 | } | |
11e09c59 TO |
89 | |
90 | /** | |
6a488035 | 91 | * Adjust Metadata for Create action |
1c88e578 | 92 | * |
6a488035 TO |
93 | * The metadata is used for setting defaults, documentation & validation |
94 | * @param array $params array or parameters determined by getfields | |
95 | */ | |
96 | function _civicrm_api3_activity_type_create_spec(&$params) { | |
97 | $params['label']['api.required'] = 1; | |
98 | $params['weight']['api.required'] = 1; | |
99 | } | |
100 | ||
101 | /** | |
102 | * Function to delete activity type | |
103 | * | |
104 | * @param activityTypeId int activity type id to delete | |
105 | * | |
106 | * @return boolen | |
107 | * | |
108 | * @access public | |
109 | * | |
110 | * @deprecated - we will introduce OptionValue Delete- plse consider helping with this if not done | |
111 | * {@example ActivityTypeDelete.php 0} | |
112 | */ | |
113 | function civicrm_api3_activity_type_delete($params) { | |
114 | ||
115 | civicrm_api3_verify_mandatory($params, NULL, array('activity_type_id')); | |
116 | ||
117 | $activityTypeId = $params['activity_type_id']; | |
6a488035 TO |
118 | |
119 | return CRM_Core_BAO_OptionValue::del($activityTypeId); | |
120 | } | |
121 |