5 +--------------------------------------------------------------------+
6 | CiviCRM version 4.3 |
7 +--------------------------------------------------------------------+
8 | Copyright CiviCRM LLC (c) 2004-2013 |
9 +--------------------------------------------------------------------+
10 | This file is a part of CiviCRM. |
12 | CiviCRM is free software; you can copy, modify, and distribute it |
13 | under the terms of the GNU Affero General Public License |
14 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
16 | CiviCRM is distributed in the hope that it will be useful, but |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
19 | See the GNU Affero General Public License for more details. |
21 | You should have received a copy of the GNU Affero General Public |
22 | License and the CiviCRM Licensing Exception along |
23 | with this program; if not, contact CiviCRM LLC |
24 | at info[AT]civicrm[DOT]org. If you have questions about the |
25 | GNU Affero General Public License or the licensing of CiviCRM, |
26 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
27 +--------------------------------------------------------------------+
31 * Definition of the ActivityType part of the CRM API.
32 * More detailed documentation can be found
33 * {@link http://objectledge.org/confluence/display/CRM/CRM+v1.0+Public+APIs
36 * @package CiviCRM_APIv3
37 * @subpackage API_Activity
39 * @copyright CiviCRM LLC (c) 2004-2013
40 * $Id: ActivityType.php 30171 2010-10-14 09:11:27Z mover $
45 * Include common API util functions
47 require_once 'CRM/Core/OptionGroup.php';
50 * Function to retrieve activity types
52 * @return array $activityTypes activity types keyed by id
55 * @example ActivityTypeGet.php
56 * @deprecated - use constant_get
58 function civicrm_api3_activity_type_get($params) {
61 $activityTypes = CRM_Core_OptionGroup
::values('activity_type');
62 return civicrm_api3_create_success($activityTypes, $params, 'activity_type', 'get');
66 * Function to create activity type (
68 * @param array $params associated array of fields
69 * $params['option_value_id'] is required for updation of activity type
71 * @return array $activityType created / updated activity type
75 *{@schema Activity/ActivityType.xml}
77 * {@example ActivityTypeCreate.php 0}
78 * @deprecated - we will introduce OptionValue Create - plse consider helping with this if not done
80 function civicrm_api3_activity_type_create($params) {
84 $groupParams = array('name' => 'activity_type');
86 if ($optionValueID = CRM_Utils_Array
::value('option_value_id', $params)) {
90 require_once 'CRM/Core/OptionValue.php';
91 $activityObject = CRM_Core_OptionValue
::addOptionValue($params, $groupParams, $action, $optionValueID);
92 $activityType = array();
93 _civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id
]);
94 return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create');
97 * Adjust Metadata for Create action
99 * The metadata is used for setting defaults, documentation & validation
100 * @param array $params array or parameters determined by getfields
102 function _civicrm_api3_activity_type_create_spec(&$params) {
103 $params['label']['api.required'] = 1;
104 $params['weight']['api.required'] = 1;
108 * Function to delete activity type
110 * @param activityTypeId int activity type id to delete
116 * @deprecated - we will introduce OptionValue Delete- plse consider helping with this if not done
117 * {@example ActivityTypeDelete.php 0}
119 function civicrm_api3_activity_type_delete($params) {
121 civicrm_api3_verify_mandatory($params, NULL, array('activity_type_id'));
123 $activityTypeId = $params['activity_type_id'];
124 require_once 'CRM/Core/BAO/OptionValue.php';
126 return CRM_Core_BAO_OptionValue
::del($activityTypeId);