Merge pull request #3679 from yashodha/CRM-14951
[civicrm-core.git] / api / v3 / Setting.php
index f23c70280de8de8512e8f0e27271be4c5ca8d419..9f71c5ab362f479b25a2acb220e1736857d7739c 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -30,7 +30,7 @@
  *
  * @package CiviCRM_APIv3_Core
  * @subpackage API_Settings
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * @version $Id: Settings.php
  *
  */
@@ -61,7 +61,7 @@ function civicrm_api3_setting_getfields($params) {
     CRM_Utils_Array::value('profile', $params, null)
   );
   // find any supplemental information
-  if(CRM_Utils_Array::value('action',$params)){
+  if (!empty($params['action'])){
     $specFunction = '_civicrm_api3_setting_' . strtolower($params['action']) . '_spec';
     if (function_exists($specFunction)) {
       $specFunction($result);
@@ -69,7 +69,8 @@ function civicrm_api3_setting_getfields($params) {
   }
   return civicrm_api3_create_success($result, $params, 'setting', 'getfields');
 }
-/*
+
+/**
  * Alter metadata for getfields functions
  */
 function _civicrm_api3_setting_getfields_spec(&$params) {
@@ -77,13 +78,14 @@ function _civicrm_api3_setting_getfields_spec(&$params) {
   $params['component_id'] = array('title' => 'id of relevant component');
   $params['profile'] = array('title' => 'profile is passed through to hooks & added to cachestring');
 }
-/*
+
+/**
  * Return default values for settings. We will domain key this as it could vary by domain (ie. urls)
  * as we will be creating the option for a function rather than an value to be in the defaults
  * Note that is not in place as yet
  */
 function civicrm_api3_setting_getdefaults(&$params){
-  $settings = civicrm_api('setting','getfields', $params);
+  $settings = civicrm_api3('setting','getfields', $params);
   $domains = _civicrm_api3_setting_getDomainArray($params);
   $defaults = array();
   foreach ($domains as $domainID){
@@ -104,11 +106,11 @@ function civicrm_api3_setting_getdefaults(&$params){
   }
   return civicrm_api3_create_success($defaults,$params,'setting','getfields');
 }
-/*
-* Metadata for setting create function
-*
-* @param array $params parameters as passed to the API
-*/
+/**
+ * Metadata for setting create function
+ *
+ * @param array $params parameters as passed to the API
+ */
 function _civicrm_api3_setting_getdefaults_spec(&$params) {
   $params['domain_id'] = array(
       'api.default' => 'current_domain',
@@ -116,7 +118,8 @@ function _civicrm_api3_setting_getdefaults_spec(&$params) {
        an array or "all" are acceptable values for multiple domains'
   );
 }
-/*
+
+/**
  * Revert settings to defaults
  */
 function civicrm_api3_setting_revert(&$params){
@@ -137,9 +140,10 @@ function civicrm_api3_setting_revert(&$params){
 
   return civicrm_api3_create_success($result, $params, 'setting', 'revert');
 }
-/*
+
+/**
  * Alter metadata for getfields functions
-*/
+ */
 function _civicrm_api3_setting_revert_spec(&$params) {
   $params['name'] = array('title' => 'Setting Name belongs to');
   $params['component_id'] = array('title' => 'id of relevant component');
@@ -150,11 +154,11 @@ function _civicrm_api3_setting_revert_spec(&$params) {
   );
 }
 
-/*
+/**
  * Revert settings to defaults
-*/
+ */
 function civicrm_api3_setting_fill(&$params){
-  $defaults = civicrm_api('setting','getdefaults', $params);
+  $defaults = civicrm_api3('setting','getdefaults', $params);
   $domains = _civicrm_api3_setting_getDomainArray($params);
   $result = array();
   foreach ($domains as $domainID){
@@ -162,7 +166,7 @@ function civicrm_api3_setting_fill(&$params){
       'version' => $params['version'],
       'domain_id' => $domainID
     );
-    $existing = civicrm_api('setting','get', $apiArray);
+    $existing = civicrm_api3('setting','get', $apiArray);
     $valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]);
     if(!empty($valuesToFill)){
       $result = array_merge($result, civicrm_api('setting', 'create', $valuesToFill + $apiArray));
@@ -170,9 +174,10 @@ function civicrm_api3_setting_fill(&$params){
   }
   return civicrm_api3_create_success($result, $params, 'setting', 'fill');
 }
-/*
+
+/**
  * Alter metadata for getfields functions
-*/
+ */
 function _civicrm_api3_setting_fill_spec(&$params) {
   $params['name'] = array('title' => 'Setting Name belongs to');
   $params['component_id'] = array('title' => 'id of relevant component');
@@ -199,7 +204,8 @@ function civicrm_api3_setting_create($params) {
   $result = CRM_Core_BAO_Setting::setItems($params, $domains);
   return civicrm_api3_create_success($result,$params,'setting','create');
 }
-/*
+
+/**
  * Metadata for setting create function
  *
  * @param array $params parameters as passed to the API
@@ -231,11 +237,11 @@ function civicrm_api3_setting_get($params) {
   $result =   $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array()));
   return civicrm_api3_create_success($result,$params,'setting','get');
 }
-/*
+/**
  * Metadata for setting create function
-*
-* @param array $params parameters as passed to the API
-*/
+ *
+ * @param array $params parameters as passed to the API
+ */
 function _civicrm_api3_setting_get_spec(&$params) {
   $params['domain_id'] = array(
       'api.default' => 'current_domain',
@@ -272,11 +278,11 @@ function civicrm_api3_setting_getvalue($params) {
   );
 }
 
-/*
+/**
  * Metadata for setting create function
-*
-* @param array $params parameters as passed to the API
-*/
+ *
+ * @param array $params parameters as passed to the API
+ */
 function _civicrm_api3_setting_getvalue_spec(&$params) {
 
   $params['group'] = array(
@@ -300,7 +306,8 @@ function _civicrm_api3_setting_getvalue_spec(&$params) {
       'description' => 'if you do not pass in a domain id this will default to the current domain'
   );
 }
-/*
+
+/**
  * Converts domain input into an array. If an array is passed in this is used, if 'all' is passed
  * in this is converted to 'all arrays'
  *