Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
731a0992 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
731a0992 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * Definition of the ActivityType part of the CRM API. | |
30 | * More detailed documentation can be found | |
31 | * {@link http://objectledge.org/confluence/display/CRM/CRM+v1.0+Public+APIs | |
32 | * here} | |
33 | * | |
34 | * @package CiviCRM_APIv3 | |
35 | * @subpackage API_Activity | |
36 | * | |
731a0992 | 37 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
38 | * $Id: ActivityType.php 30171 2010-10-14 09:11:27Z mover $ |
39 | * | |
40 | */ | |
41 | ||
6a488035 TO |
42 | /** |
43 | * Function to retrieve activity types | |
44 | * | |
77b97be7 EM |
45 | * @param $params |
46 | * | |
6a488035 TO |
47 | * @return array $activityTypes activity types keyed by id |
48 | * @access public | |
49 | * | |
50 | * @example ActivityTypeGet.php | |
4e420887 | 51 | * @deprecated - use getoptions |
6a488035 TO |
52 | */ |
53 | function civicrm_api3_activity_type_get($params) { | |
54 | ||
6a488035 TO |
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 | * | |
6a488035 TO |
69 | * @deprecated - we will introduce OptionValue Create - plse consider helping with this if not done |
70 | */ | |
71 | function civicrm_api3_activity_type_create($params) { | |
72 | ||
6a488035 TO |
73 | $action = 1; |
74 | $groupParams = array('name' => 'activity_type'); | |
75 | ||
76 | if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) { | |
77 | $action = 2; | |
78 | } | |
79 | ||
6a488035 TO |
80 | $activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID); |
81 | $activityType = array(); | |
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 | /** | |
6a488035 | 87 | * Adjust Metadata for Create action |
1c88e578 | 88 | * |
6a488035 TO |
89 | * The metadata is used for setting defaults, documentation & validation |
90 | * @param array $params array or parameters determined by getfields | |
91 | */ | |
92 | function _civicrm_api3_activity_type_create_spec(&$params) { | |
93 | $params['label']['api.required'] = 1; | |
94 | $params['weight']['api.required'] = 1; | |
95 | } | |
96 | ||
97 | /** | |
98 | * Function to delete activity type | |
99 | * | |
4e420887 | 100 | * @param array $params array including id of activity_type to delete |
101 | ||
102 | * @return array API result array | |
6a488035 TO |
103 | * |
104 | * @access public | |
105 | * | |
106 | * @deprecated - we will introduce OptionValue Delete- plse consider helping with this if not done | |
6a488035 TO |
107 | */ |
108 | function civicrm_api3_activity_type_delete($params) { | |
4e420887 | 109 | return civicrm_api3_create_success(CRM_Core_BAO_OptionValue::del($params['id']), $params); |
6a488035 TO |
110 | } |
111 |