3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 * @package CiviCRM_APIv3
33 * @subpackage API_Constant
34 * @copyright CiviCRM LLC (c) 2004-2014
35 * @version $Id: Constant.php 30171 2010-10-14 09:11:27Z mover $
39 * Declare deprecated api entity.
41 * @deprecated api notice
43 * to indicate this entire api entity is deprecated
45 function _civicrm_api3_constant_deprecation() {
46 return 'The constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.';
50 * Get constant values (deprecated).
52 * @deprecated as of CiviCRM 4.4.
53 * It's recommended to use the api getoptions action instead
55 * @param array $params
56 * Name of a public static method of
57 * CRM_Core_PseudoConstant: one of
59 * <li>activityStatus</li>
60 * <li>activityType</li>
64 * <li>countryIsoCode</li>
66 * <li>currencyCode</li>
67 * <li>currencySymbols</li>
68 * <li>customGroup</li>
69 * <li>emailGreeting</li>
70 * <li>fromEmailAddress</li>
73 * <li>groupIterator</li>
76 * <li>individualPrefix</li>
77 * <li>individualSuffix</li>
78 * <li>locationType</li>
79 * <li>locationVcardName</li>
80 * <li>mailProtocol</li>
81 * <li>mappingTypes</li>
82 * <li>paymentProcessor</li>
83 * <li>paymentProcessorType</li>
86 * <li>postalGreeting</li>
88 * <li>relationshipType</li>
89 * <li>stateProvince</li>
90 * <li>stateProvinceAbbreviation</li>
91 * <li>stateProvinceForCountry</li>
92 * <li>staticGroup</li>
97 * <li>worldRegion</li>
98 * <li>wysiwygEditor</li>
103 function civicrm_api3_constant_get($params) {
105 $name = $params['name'];
106 // all the stuff about classes should be adequately replaced by the bit in the 'else'
107 //ie $values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
108 // once tests are 100% can try removing the first block & a similar block from Generic:getoptions
110 // Whitelist approach is safer
111 $allowedClasses = array(
112 'CRM_Core_PseudoConstant',
113 'CRM_Event_PseudoConstant',
114 'CRM_Contribute_PseudoConstant',
115 'CRM_Member_PseudoConstant',
117 $className = $allowedClasses[0];
118 if (!empty($params['class']) && in_array($params['class'], $allowedClasses)) {
119 $className = $params['class'];
121 $callable = "$className::$name";
122 if (is_callable($callable)) {
123 if (empty($params)) {
124 $values = call_user_func(array($className, $name));
127 $values = call_user_func(array($className, $name));
128 //@TODO XAV take out the param the COOKIE, Entity, Action and so there are only the "real param" in it
129 //$values = call_user_func_array( array( $className, $name ), $params );
131 return civicrm_api3_create_success($values, $params, 'constant');
134 $values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
135 if (!empty($values)) {
136 return civicrm_api3_create_success($values, $params, 'constant');
139 return civicrm_api3_create_error('Unknown civicrm constant or method not callable');
143 * Adjust metadata for constant get action.
145 * @param array $params
147 function _civicrm_api3_constant_get_spec(&$params) {
174 'paymentProcessorType',
181 'stateProvinceAbbreviation',
182 'stateProvinceForCountry',
193 'title' => 'Constant Name',
196 'options' => array_combine($options, $options),