| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
| 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 | * The ActivityType api is deprecated. Please use the OptionValue api instead. |
| 30 | * |
| 31 | * @deprecated |
| 32 | * |
| 33 | * @package CiviCRM_APIv3 |
| 34 | */ |
| 35 | |
| 36 | /** |
| 37 | * Notification of deprecated function. |
| 38 | * |
| 39 | * @deprecated api notice |
| 40 | * @return string |
| 41 | * to indicate this entire api entity is deprecated |
| 42 | */ |
| 43 | function _civicrm_api3_activity_type_deprecation() { |
| 44 | return 'The ActivityType api is deprecated. Please use the OptionValue api instead.'; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Retrieve activity types. |
| 49 | * |
| 50 | * @param array $params |
| 51 | * |
| 52 | * @return array |
| 53 | * activity types keyed by id |
| 54 | * @deprecated - use the getoptions action instead |
| 55 | */ |
| 56 | function civicrm_api3_activity_type_get($params) { |
| 57 | |
| 58 | $activityTypes = CRM_Core_OptionGroup::values('activity_type'); |
| 59 | return civicrm_api3_create_success($activityTypes, $params, 'activity_type', 'get'); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Create activity type. |
| 64 | * |
| 65 | * @param array $params |
| 66 | * |
| 67 | * @return array |
| 68 | * created / updated activity type |
| 69 | * |
| 70 | * @deprecated use the OptionValue api instead |
| 71 | */ |
| 72 | function civicrm_api3_activity_type_create($params) { |
| 73 | |
| 74 | $action = 1; |
| 75 | $groupParams = array('name' => 'activity_type'); |
| 76 | |
| 77 | if ($optionValueID = CRM_Utils_Array::value('option_value_id', $params)) { |
| 78 | $action = 2; |
| 79 | } |
| 80 | |
| 81 | $activityObject = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $action, $optionValueID); |
| 82 | $activityType = array(); |
| 83 | _civicrm_api3_object_to_array($activityObject, $activityType[$activityObject->id]); |
| 84 | return civicrm_api3_create_success($activityType, $params, 'activity_type', 'create'); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Adjust Metadata for Create action. |
| 89 | * |
| 90 | * The metadata is used for setting defaults, documentation & validation. |
| 91 | * |
| 92 | * @param array $params |
| 93 | * Array of parameters determined by getfields. |
| 94 | */ |
| 95 | function _civicrm_api3_activity_type_create_spec(&$params) { |
| 96 | $params['label'] = array( |
| 97 | 'api.required' => 1, |
| 98 | 'title' => 'Label', |
| 99 | 'type' => CRM_Utils_Type::T_STRING, |
| 100 | ); |
| 101 | $params['weight'] = array( |
| 102 | 'api.required' => 1, |
| 103 | 'title' => 'Weight', |
| 104 | 'type' => CRM_Utils_Type::T_STRING, |
| 105 | ); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Delete ActivityType. |
| 110 | * |
| 111 | * @param array $params |
| 112 | * Array including id of activity_type to delete. |
| 113 | * @return array API result array |
| 114 | * @throws API_Exception |
| 115 | * @deprecated use OptionValue api |
| 116 | */ |
| 117 | function civicrm_api3_activity_type_delete($params) { |
| 118 | $result = CRM_Core_BAO_OptionValue::del($params['id']); |
| 119 | if ($result) { |
| 120 | return civicrm_api3_create_success(TRUE, $params); |
| 121 | } |
| 122 | throw new API_Exception("Failure to delete activity type id {$params['id']}"); |
| 123 | } |