<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* @param array $params
*/
function _civicrm_api3_setting_getfields_spec(&$params) {
- $params['filters'] = array('title' => 'Fields you wish to filter by e.g. array("group_name" => "CiviCRM Preferences")');
- $params['component_id'] = array('title' => 'id of relevant component');
- $params['profile'] = array('title' => 'profile is passed through to hooks & added to cachestring');
+ $params['filters'] = array(
+ 'title' => 'Filters',
+ 'description' => 'Fields you wish to filter by e.g. array("group_name" => "CiviCRM Preferences")',
+ );
+ $params['component_id'] = array(
+ 'title' => 'Component ID',
+ 'description' => 'ID of relevant component',
+ );
+ $params['profile'] = array(
+ 'title' => 'Profile',
+ 'description' => 'Profile is passed through to hooks & added to cachestring',
+ );
}
/**
);
}
+function civicrm_api3_setting_getoptions($params) {
+ $specs = CRM_Core_BAO_Setting::getSettingSpecification();
+
+ if (empty($specs[$params['field']]) || empty($specs[$params['field']]['pseudoconstant'])) {
+ throw new API_Exception("The field '" . $params['field'] . "' has no associated option list.");
+ }
+
+ $pseudoconstant = $specs[$params['field']]['pseudoconstant'];
+
+ // It would be nice if we could leverage CRM_Core_PseudoConstant::get() somehow,
+ // but it's tightly coupled to DAO/field. However, if you really need to support
+ // more pseudoconstant types, then probably best to refactor it. For now, KISS.
+ if (!empty($pseudoconstant['callback'])) {
+ $values = Civi\Core\Resolver::singleton()->call($pseudoconstant['callback'], array());
+ return civicrm_api3_create_success($values, $params, 'Setting', 'getoptions');
+ }
+
+ throw new API_Exception("The field '" . $params['field'] . "' uses an unsupported option list.");
+}
+
/**
* Revert settings to defaults.
*
* @param array $params
*/
function _civicrm_api3_setting_revert_spec(&$params) {
- $params['name'] = array('title' => 'Setting Name belongs to');
- $params['component_id'] = array('title' => 'id of relevant component');
+ $params['name'] = array(
+ 'title' => 'Name',
+ 'description' => 'Setting Name belongs to',
+ );
+ $params['component_id'] = array(
+ 'title' => 'Component ID',
+ 'description' => 'ID of relevant component',
+ );
$params['domain_id'] = array(
'api.default' => 'current_domain',
'description' => 'Defaults may differ by domain - if you do not pass in a domain id this will default to the current domain'
* @param array $params
*/
function _civicrm_api3_setting_fill_spec(&$params) {
- $params['name'] = array('title' => 'Setting Name belongs to');
- $params['component_id'] = array('title' => 'id of relevant component');
+ $params['name'] = array(
+ 'title' => 'Name',
+ 'description' => 'Setting Name belongs to',
+ );
+ $params['component_id'] = array(
+ 'title' => 'Component ID',
+ 'description' => 'ID of relevant component',
+ );
$params['domain_id'] = array(
'api.default' => 'current_domain',
'title' => 'Setting Domain',
* API result array.
*/
function civicrm_api3_setting_getvalue($params) {
- $config = CRM_Core_Config::singleton();
- if (isset($config->$params['name'])) {
- return $config->$params['name'];
- }
+ //$config = CRM_Core_Config::singleton();
+ //if (isset($config->$params['name'])) {
+ // return $config->$params['name'];
+ //}
return CRM_Core_BAO_Setting::getItem(
$params['group'],
CRM_Utils_Array::value('name', $params),