2a79466a090ddaae911138c6fa3ba024ccc0e113
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * CiviCRM APIv3 pseudoconstants
32 * The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.
33 * @package CiviCRM_APIv3
37 * Declare deprecated api entity.
39 * @deprecated api notice
41 * to indicate this entire api entity is deprecated
43 function _civicrm_api3_constant_deprecation() {
44 return 'The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.';
48 * Get constant values (deprecated).
50 * @deprecated as of CiviCRM 4.4.
51 * It's recommended to use the api getoptions action instead
53 * @param array $params
54 * Name of a public static method of
55 * CRM_Core_PseudoConstant: one of
80 * paymentProcessorType
87 * stateProvinceAbbreviation
88 * stateProvinceForCountry
99 function civicrm_api3_constant_get($params) {
101 $name = $params['name'];
102 // all the stuff about classes should be adequately replaced by the bit in the 'else'
103 //ie $values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
104 // once tests are 100% can try removing the first block & a similar block from Generic:getoptions
106 // Whitelist approach is safer
107 $allowedClasses = array(
108 'CRM_Core_PseudoConstant',
109 'CRM_Event_PseudoConstant',
110 'CRM_Contribute_PseudoConstant',
111 'CRM_Member_PseudoConstant',
113 $className = $allowedClasses[0];
114 if (!empty($params['class']) && in_array($params['class'], $allowedClasses)) {
115 $className = $params['class'];
117 $callable = "$className::$name";
118 if (is_callable($callable)) {
119 if (empty($params)) {
120 $values = call_user_func(array($className, $name));
123 $values = call_user_func(array($className, $name));
124 //@TODO XAV take out the param the COOKIE, Entity, Action and so there are only the "real param" in it
125 //$values = call_user_func_array( array( $className, $name ), $params );
127 return civicrm_api3_create_success($values, $params, 'Constant');
130 $values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
131 if (!empty($values)) {
132 return civicrm_api3_create_success($values, $params, 'Constant');
135 return civicrm_api3_create_error('Unknown civicrm constant or method not callable');
139 * Adjust metadata for constant get action.
141 * @param array $params
143 function _civicrm_api3_constant_get_spec(&$params) {
170 'paymentProcessorType',
177 'stateProvinceAbbreviation',
178 'stateProvinceForCountry',
189 'title' => 'Constant Name',
192 'options' => array_combine($options, $options),
193 'type' => CRM_Utils_Type
::T_STRING
,