3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
21 * Retrieve CiviCRM settings from the api for use in templates.
26 * @return int|string|null
28 function smarty_function_crmSetting($params, &$smarty) {
30 $errorScope = CRM_Core_TemporaryErrorScope
::create(['CRM_Utils_REST', 'fatal']);
31 unset($params['method']);
32 unset($params['assign']);
33 $params['version'] = 3;
35 require_once 'api/api.php';
36 $result = civicrm_api('setting', 'getvalue', $params);
38 // Core-688 FALSE is returned by Boolean settings, thus giving false errors.
39 if ($result === NULL) {
40 $smarty->trigger_error("Unknown error");
44 if (empty($params['var'])) {
45 return is_numeric($result) ?
$result : json_encode($result);
47 if (!empty($params['json'])) {
48 $smarty->assign($params["var"], json_encode($result));
51 $smarty->assign($params["var"], $result);