3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * BAO object for civicrm_setting table. This table is used to store civicrm settings that are not used
38 * very frequently (i.e. not on every page load)
40 * The group column is used for grouping together all settings that logically belong to the same set.
41 * Thus all settings in the same group are retrieved with one DB call and then cached for future needs.
44 class CRM_Core_BAO_Setting
extends CRM_Core_DAO_Setting
{
47 * various predefined settings that have been migrated to the setting table
50 ADDRESS_STANDARDIZATION_PREFERENCES_NAME
= 'Address Standardization Preferences',
51 CAMPAIGN_PREFERENCES_NAME
= 'Campaign Preferences',
52 DIRECTORY_PREFERENCES_NAME
= 'Directory Preferences',
53 EVENT_PREFERENCES_NAME
= 'Event Preferences',
54 MAILING_PREFERENCES_NAME
= 'Mailing Preferences',
55 CONTRIBUTE_PREFERENCES_NAME
= 'Contribute Preferences',
56 MEMBER_PREFERENCES_NAME
= 'Member Preferences',
57 MULTISITE_PREFERENCES_NAME
= 'Multi Site Preferences',
58 PERSONAL_PREFERENCES_NAME
= 'Personal Preferences',
59 SYSTEM_PREFERENCES_NAME
= 'CiviCRM Preferences',
60 URL_PREFERENCES_NAME
= 'URL Preferences',
61 LOCALIZATION_PREFERENCES_NAME
= 'Localization Preferences',
62 SEARCH_PREFERENCES_NAME
= 'Search Preferences';
63 static $_cache = NULL;
66 * Checks whether an item is present in the in-memory cache table
68 * @param string $group (required) The group name of the item
69 * @param string $name (required) The name of the setting
70 * @param int $componentID The optional component ID (so componenets can share the same name space)
71 * @param int $contactID If set, this is a contactID specific setting, else its a global setting
72 * @param int $load if true, load from local cache (typically memcache)
74 * @return boolean true if item is already in cache
78 static function inCache($group,
85 if (!isset(self
::$_cache)) {
86 self
::$_cache = array();
89 $cacheKey = "CRM_Setting_{$group}_{$componentID}_{$contactID}_{$domainID}";
91 !isset(self
::$_cache[$cacheKey])
93 // check in civi cache if present (typically memcache)
94 $globalCache = CRM_Utils_Cache
::singleton();
95 $result = $globalCache->get($cacheKey);
97 self
::$_cache[$cacheKey] = $result;
101 return isset(self
::$_cache[$cacheKey]) ?
$cacheKey : NULL;
104 static function setCache($values,
110 if (!isset(self
::$_cache)) {
111 self
::$_cache = array();
114 $cacheKey = "CRM_Setting_{$group}_{$componentID}_{$contactID}_{$domainID}";
116 self
::$_cache[$cacheKey] = $values;
118 $globalCache = CRM_Utils_Cache
::singleton();
119 $result = $globalCache->set($cacheKey, $values);
124 static function dao($group,
130 $dao = new CRM_Core_DAO_Setting();
132 $dao->group_name
= $group;
134 $dao->component_id
= $componentID;
135 if (empty($domainID)) {
136 $dao->domain_id
= CRM_Core_Config
::domainID();
139 $dao->domain_id
= $domainID;
143 $dao->contact_id
= $contactID;
154 * Retrieve the value of a setting from the DB table
156 * @param string $group (required) The group name of the item
157 * @param string $name (required) The name under which this item is stored
158 * @param int $componentID The optional component ID (so componenets can share the same name space)
159 * @param string $defaultValue The default value to return for this setting if not present in DB
160 * @param int $contactID If set, this is a contactID specific setting, else its a global setting
163 * @return object The data if present in the setting table, else null
167 static function getItem($group,
170 $defaultValue = NULL,
175 if (NULL !== ($override = self
::getOverride($group, $name, NULL))) {
179 if (empty($domainID)) {
180 $domainID = CRM_Core_Config
::domainID();
182 $cacheKey = self
::inCache($group, $name, $componentID, $contactID, TRUE, $domainID);
184 $dao = self
::dao($group, NULL, $componentID, $contactID, $domainID);
188 while ($dao->fetch()) {
189 if (NULL !== ($override = self
::getOverride($group, $dao->name
, NULL))) {
190 $values[$dao->name
] = $override;
192 elseif ($dao->value
) {
193 $values[$dao->name
] = unserialize($dao->value
);
196 $values[$dao->name
] = NULL;
201 $cacheKey = self
::setCache($values, $group, $componentID, $contactID, $domainID);
204 return $name ? CRM_Utils_Array
::value($name, self
::$_cache[$cacheKey], $defaultValue) : self
::$_cache[$cacheKey];
208 * Store multiple items in the setting table
210 * @param array $params (required) An api formatted array of keys and values
211 * @domains array an array of domains to get settings for. Default is the current domain
216 static function getItems(&$params, $domains = null, $settingsToReturn) {
217 if (empty($domains)) {
218 $domains[] = CRM_Core_Config
::domainID();
220 if (!empty($settingsToReturn) && !is_array($settingsToReturn)) {
221 $settingsToReturn = array($settingsToReturn);
223 $config = CRM_Core_Config
::singleton();
224 $fields = $result = array();
225 $fieldsToGet = self
::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE);
226 foreach ($domains as $domain) {
227 $result[$domain] = array();
228 foreach ($fieldsToGet as $name => $value) {
229 if(!empty($fields['values'][$name]['prefetch'])){
230 $configKey = CRM_Utils_Array
::value('config_key', $fields['values'][$name], $name);
231 if(isset($config->$configKey)){
232 $setting = $config->$configKey;
237 CRM_Core_BAO_Setting
::getItem(
238 $fields['values'][$name]['group_name'],
240 CRM_Utils_Array
::value('component_id', $params),
241 CRM_Utils_Array
::value('default_value', $params),
242 CRM_Utils_Array
::value('contact_id', $params),
246 if (!is_null($setting)) {
247 // we won't return if not set - helps in return all scenario - otherwise we can't indentify the missing ones
248 // e.g for revert of fill actions
249 $result[$domain][$name] = $setting;
257 * Store an item in the setting table
259 * @param object $value (required) The value that will be serialized and stored
260 * @param string $group (required) The group name of the item
261 * @param string $name (required) The name of the setting
262 * @param int $componentID The optional component ID (so componenets can share the same name space)
263 * @param int $createdID An optional ID to assign the creator to. If not set, retrieved from session
269 static function setItem(
279 if (empty($domainID)) {
280 $domainID = CRM_Core_Config
::domainID();
283 $dao = self
::dao($group, $name, $componentID, $contactID, $domainID);
286 if (CRM_Utils_System
::isNull($value)) {
287 $dao->value
= 'null';
290 $dao->value
= serialize($value);
293 $dao->created_date
= date('Ymdhis');
296 $dao->created_id
= $createdID;
299 $session = CRM_Core_Session
::singleton();
300 $createdID = $session->get('userID');
303 // ensure that this is a valid contact id (for session inconsistency rules)
304 $cid = CRM_Core_DAO
::getFieldValue('CRM_Contact_DAO_Contact',
310 $dao->created_id
= $session->get('userID');
318 // also save in cache if needed
319 $cacheKey = self
::inCache($group, $name, $componentID, $contactID, FALSE, $domainID);
321 self
::$_cache[$cacheKey][$name] = $value;
326 * Store multiple items in the setting table. Note that this will also store config keys
327 * the storage is determined by the metdata and is affected by
328 * 'name' setting's name
329 * 'prefetch' = store in config
330 * 'config_only' = don't store in settings
331 * 'config_key' = the config key is different to the settings key - e.g. debug where there was a conflict
332 * 'legacy_key' = rename from config or setting with this name
334 * @param array $params (required) An api formatted array of keys and values
335 * @domains array an array of domains to get settings for. Default is the current domain
340 static function setItems(&$params, $domains = null) {
341 if (empty($domains)) {
342 $domains[] = CRM_Core_Config
::domainID();
344 $fields = $config_keys = array();
345 $fieldsToSet = self
::validateSettingsInput($params, $fields);
347 foreach ($fieldsToSet as $settingField => &$settingValue) {
348 self
::validateSetting($settingValue, $fields['values'][$settingField]);
351 foreach ($domains as $domain) {
352 $result[$domain] = array();
353 foreach ($fieldsToSet as $name => $value) {
354 if(empty($fields['values'][$name]['config_only'])){
355 CRM_Core_BAO_Setting
::setItem(
357 $fields['values'][$name]['group_name'],
359 CRM_Utils_Array
::value('component_id', $params),
360 CRM_Utils_Array
::value('contact_id', $params),
361 CRM_Utils_Array
::value('created_id', $params),
365 if(!empty($fields['values'][$name]['prefetch'])){
366 if(!empty($fields['values'][$name]['config_key'])){
367 $name = $fields['values'][$name]['config_key'];
369 $config_keys[$name] = $value;
371 $result[$domain][$name] = $value;
373 CRM_Core_BAO_ConfigSetting
::create($config_keys);
380 * gets metadata about the settings fields (from getfields) based on the fields being passed in
382 * This function filters on the fields like 'version' & 'debug' that are not settings
383 * @param array $params Parameters as passed into API
384 * @param array $fields empty array to be populated with fields metadata
385 * @param bool $createMode
387 * @return array $fieldstoset name => value array of the fields to be set (with extraneous removed)
389 static function validateSettingsInput($params, &$fields, $createMode = TRUE) {
390 $group = CRM_Utils_Array
::value('group', $params);
392 $ignoredParams = array(
409 $settingParams = array_diff_key($params, array_fill_keys($ignoredParams, TRUE));
410 $getFieldsParams = array('version' => 3);
411 if (count($settingParams) ==1) {
412 // ie we are only setting one field - we'll pass it into getfields for efficiency
413 list($name) = array_keys($settingParams);
414 $getFieldsParams['name'] = $name;
416 $fields = civicrm_api('setting','getfields', $getFieldsParams);
417 $invalidParams = (array_diff_key($settingParams, $fields['values']));
418 if (!empty($invalidParams)) {
419 throw new api_Exception(implode(',', $invalidParams) . " not valid settings");
421 if (!empty($settingParams)) {
422 $filteredFields = array_intersect_key($settingParams, $fields['values']);
425 // no filters so we are interested in all for get mode. In create mode this means nothing to set
426 $filteredFields = $createMode ?
array() : $fields['values'];
428 return $filteredFields;
432 * Validate & convert settings input
434 * @value mixed value of the setting to be set
435 * @fieldSpec array Metadata for given field (drawn from the xml)
437 static function validateSetting(&$value, $fieldSpec) {
438 if($fieldSpec['type'] == 'String' && is_array($value)){
439 $value = CRM_Core_DAO
::VALUE_SEPARATOR
. implode(CRM_Core_DAO
::VALUE_SEPARATOR
,$value) . CRM_Core_DAO
::VALUE_SEPARATOR
;
441 if (empty($fieldSpec['validate_callback'])) {
445 list($class,$fn) = explode('::',$fieldSpec['validate_callback']);
446 if (!$class::$fn($value,$fieldSpec)) {
447 throw new api_Exception("validation failed for {$fieldSpec['name']} = $value based on callback {$fieldSpec['validate_callback']}");
453 * Validate & convert settings input - translate True False to 0 or 1
455 * @value mixed value of the setting to be set
456 * @fieldSpec array Metadata for given field (drawn from the xml)
458 static function validateBoolSetting(&$value, $fieldSpec) {
459 if (!CRM_Utils_Rule
::boolean($value)) {
460 throw new api_Exception("Boolean value required for {$fieldSpec['name']}");
472 * Delete some or all of the items in the settings table
474 * @param string $group The group name of the entries to be deleted
475 * @param string $name The name of the setting to be deleted
476 * @param int $componentID The optional component ID (so componenets can share the same name space)
482 static function deleteItem($group, $name = NULL, $componentID = NULL, $contactID = NULL) {
483 $dao = self::dao($group, $name, $componentID, $contactID);
486 // also reset memory cache if any
487 CRM_Utils_System::flushCache();
489 $cacheKey = self::inCache($group, $name, $componentID, $contactID, FALSE);
492 unset(self::$_cache[$cacheKey][$name]);
495 unset(self::$_cache[$cacheKey]);
501 * This provides information about the setting - similar to the fields concept for DAO information.
502 * As the setting is serialized code creating validation setting input needs to know the data type
503 * This also helps move information out of the form layer into the data layer where people can interact with
504 * it via the API or other mechanisms. In order to keep this consistent it is important the form layer
507 * Note that this function should never be called when using the runtime getvalue function. Caching works
508 * around the expectation it will be called during setting administration
510 * Function is intended for configuration rather than runtime access to settings
512 * The following params will filter the result. If none are passed all settings will be returns
514 * @params string $name Name of specific setting e.g customCSSURL
515 * @params integer $componentID id of relevant component.
517 * @return array $result - the following information as appropriate for each setting
521 * - add (CiviCRM version added)
527 static function getSettingSpecification($componentID = null, $filters = array(), $domainID = null, $profile = null) {
529 $cacheString = 'settingsMetadata_' . $domainID . '_' . $profile;
530 foreach ($filters as $filterField => $filterString) {
531 $cacheString .= "_{$filterField}_{$filterString}";
534 $settingsMetadata = CRM_Core_BAO_Cache
::getItem('CiviCRM setting Specs', $cacheString, $componentID);
535 if ($settingsMetadata === NULL) {
536 $settingsMetadata = CRM_Core_BAO_Cache
::getItem('CiviCRM setting Spec', 'All', $componentID);
537 if (empty($settingsMetadata)) {
538 $settingsMetadata = array();
539 global $civicrm_root;
540 $metaDataFolders = array($civicrm_root. '/settings');
541 CRM_Utils_Hook
::alterSettingsFolders($metaDataFolders);
542 foreach ($metaDataFolders as $metaDataFolder) {
543 $settingsMetadata = $settingsMetadata + self
::loadSettingsMetaData($metaDataFolder);
545 CRM_Core_BAO_Cache
::setItem($settingsMetadata,'CiviCRM setting Spec', 'All', $componentID);
550 $hookCacheString = CRM_Utils_Hook
::alterSettingsMetaData($settingsMetadata, $domainID, $profile);
551 self
::_filterSettingsSpecification($filters, $settingsMetadata);
552 if(!$cached ||
!empty($hookCacheString)){
553 // this is a bit 'heavy' if you are using hooks but this function is expected to only be called during setting administration
554 // it should not be called by 'getvalue' or 'getitem
555 CRM_Core_BAO_Cache
::setItem($settingsMetadata,'CiviCRM setting Specs', $cacheString . $hookCacheString, $componentID);
557 return $settingsMetadata;
562 * Load up settings metadata from files
564 static function loadSettingsMetadata($metaDataFolder) {
565 $settingMetaData = array();
566 $settingsFiles = CRM_Utils_File
::findFiles($metaDataFolder, '*.setting.php');
567 foreach ($settingsFiles as $file) {
568 $settings = include $file;
569 $settingMetaData = array_merge($settingMetaData, $settings);
571 CRM_Core_BAO_Cache
::setItem($settingMetaData,'CiviCRM setting Spec', 'All');
572 return $settingMetaData;
576 * Filter the settings metadata according to filters passed in. This is a convenience filter
577 * and allows selective reverting / filling of settings
579 * @param array $filters Filters to match against data
580 * @param array $settingSpec metadata to filter
582 static function _filterSettingsSpecification($filters, &$settingSpec) {
583 if (empty($filters)) {
586 else if (array_keys($filters) == array('name')) {
587 $settingSpec = array($filters['name'] => $settingSpec[$filters['name']]);
591 foreach ($settingSpec as $field => $fieldValues) {
592 if (array_intersect_assoc($fieldValues, $filters) != $filters) {
593 unset($settingSpec[$field]);
601 * Look for any missing settings and convert them from config or load default as appropriate
602 * This should be run from GenCode & also from upgrades to add any new defaults.
604 * Multisites have often been overlooked in upgrade scripts so can be expected to be missing
605 * a number of settings
607 static function updateSettingsFromMetaData() {
610 'domain_id' => 'all',
612 $existing = civicrm_api('setting', 'get', $apiParams);
613 if (!empty($existing['values'])) {
614 $allSettings = civicrm_api('setting', 'getfields', array('version' => 3));
615 foreach ($existing['values'] as $domainID => $domainSettings) {
616 CRM_Core_BAO_Domain
::setDomain($domainID);
617 $missing = array_diff_key($allSettings['values'], $domainSettings);
618 foreach ($missing as $name => $settings) {
619 self
::convertConfigToSetting($name, $domainID);
621 CRM_Core_BAO_Domain
::resetDomain();
627 * move an item from being in the config array to being stored as a setting
628 * remove from config - as appropriate based on metadata
630 * Note that where the key name is being changed the 'legacy_key' will give us the old name
632 static function convertConfigToSetting($name, $domainID = null) {
633 $config = CRM_Core_Config
::singleton();
634 if (empty($domainID)) {
635 $domainID= CRM_Core_Config
::domainID();
637 $domain = new CRM_Core_DAO_Domain();
638 $domain->id
= $domainID;
640 if ($domain->config_backend
) {
641 $values = unserialize($domain->config_backend
);
645 $spec = self
::getSettingSpecification(null, array('name' => $name), $domainID);
646 $configKey = CRM_Utils_Array
::value('config_key', $spec[$name], CRM_Utils_Array
::value('legacy_key', $spec[$name], $name));
647 //if the key is set to config_only we don't need to do anything
648 if(empty($spec[$name]['config_only'])){
649 if (!empty($values[$configKey])) {
650 civicrm_api('setting', 'create', array('version' => 3, $name => $values[$configKey], 'domain_id' => $domainID));
653 civicrm_api('setting', 'fill', array('version' => 3, 'name' => $name, 'domain_id' => $domainID));
656 if (empty($spec[$name]['prefetch']) && !empty($values[$configKey])) {
657 unset($values[$configKey]);
658 $domain->config_backend
= serialize($values);
660 unset($config->$configKey);
665 static function valueOptions($group,
670 $returnField = 'name',
671 $returnNameANDLabels = FALSE,
674 $optionValue = self
::getItem($group, $name);
676 $groupValues = CRM_Core_OptionGroup
::values($name, FALSE, FALSE, $localize, $condition, $returnField);
678 //enabled name => label require for new contact edit form, CRM-4605
679 if ($returnNameANDLabels) {
680 $names = $labels = $nameAndLabels = array();
681 if ($returnField == 'name') {
682 $names = $groupValues;
683 $labels = CRM_Core_OptionGroup
::values($name, FALSE, FALSE, $localize, $condition, 'label');
686 $labels = $groupValues;
687 $names = CRM_Core_OptionGroup
::values($name, FALSE, FALSE, $localize, $condition, 'name');
691 $returnValues = array();
692 foreach ($groupValues as $gn => $gv) {
693 $returnValues[$gv] = 0;
696 if ($optionValue && !empty($groupValues)) {
697 $dbValues = explode(CRM_Core_DAO
::VALUE_SEPARATOR
,
698 substr($optionValue, 1, -1)
701 if (!empty($dbValues)) {
702 foreach ($groupValues as $key => $val) {
703 if (in_array($key, $dbValues)) {
704 $returnValues[$val] = 1;
705 if ($returnNameANDLabels) {
706 $nameAndLabels[$names[$key]] = $labels[$key];
712 return ($returnNameANDLabels) ?
$nameAndLabels : $returnValues;
715 static function setValueOption($group,
725 elseif (is_array($value)) {
726 $groupValues = CRM_Core_OptionGroup
::values($name, FALSE, FALSE, FALSE, NULL, $keyField);
729 foreach ($groupValues as $key => $val) {
730 if (CRM_Utils_Array
::value($val, $value)) {
735 if (!empty($cbValues)) {
736 $optionValue = CRM_Core_DAO
::VALUE_SEPARATOR
. implode(CRM_Core_DAO
::VALUE_SEPARATOR
,
737 array_keys($cbValues)
738 ) . CRM_Core_DAO
::VALUE_SEPARATOR
;
745 $optionValue = $value;
748 self
::setItem($optionValue, $group, $name);
751 static function fixAndStoreDirAndURL(&$params, $domainID = null) {
752 if (empty($domainID)) {
753 $domainID = CRM_Core_Config
::domainID();
756 SELECT name, group_name
759 AND ( group_name = %2
763 1 => array($domainID, 'Integer'),
764 2 => array(self
::DIRECTORY_PREFERENCES_NAME
, 'String'),
765 3 => array(self
::URL_PREFERENCES_NAME
, 'String'),
768 $dirParams = array();
769 $urlParams = array();
771 $dao = CRM_Core_DAO
::executeQuery($sql,
777 // trap exceptions as error
781 if (is_a($dao, 'DB_Error')) {
782 if (CRM_Core_Config
::isUpgradeMode()) {
783 // seems like this is a 4.0 -> 4.1 upgrade, so we suppress this error and continue
787 echo "Fatal DB error, exiting, seems like your schema does not have civicrm_setting table\n";
792 while ($dao->fetch()) {
793 if (!isset($params[$dao->name
])) {
796 if ($dao->group_name
== self
::DIRECTORY_PREFERENCES_NAME
) {
797 $dirParams[$dao->name
] = CRM_Utils_Array
::value($dao->name
, $params, '');
800 $urlParams[$dao->name
] = CRM_Utils_Array
::value($dao->name
, $params, '');
802 unset($params[$dao->name
]);
805 if (!empty($dirParams)) {
806 self
::storeDirectoryOrURLPreferences($dirParams,
807 self
::DIRECTORY_PREFERENCES_NAME
811 if (!empty($urlParams)) {
812 self
::storeDirectoryOrURLPreferences($urlParams,
813 self
::URL_PREFERENCES_NAME
818 static function storeDirectoryOrURLPreferences(&$params, $group) {
819 foreach ($params as $name => $value) {
820 // always try to store relative directory or url from CMS root
821 $value = ($group == self
::DIRECTORY_PREFERENCES_NAME
) ? CRM_Utils_File
::relativeDirectory($value) : CRM_Utils_System
::relativeURL($value);
823 self
::setItem($value, $group, $name);
827 static function retrieveDirectoryAndURLPreferences(&$params, $setInConfig = FALSE) {
829 $config = CRM_Core_Config
::singleton();
832 $isJoomla = (defined('CIVICRM_UF') && CIVICRM_UF
== 'Joomla') ?
TRUE : FALSE;
834 if (CRM_Core_Config
::isUpgradeMode() && !$isJoomla) {
835 $currentVer = CRM_Core_BAO_Domain
::version();
836 if (version_compare($currentVer, '4.1.alpha1') < 0) {
841 SELECT name, group_name, value
843 WHERE ( group_name = %1
847 $sqlParams = array(1 => array(self
::DIRECTORY_PREFERENCES_NAME
, 'String'),
848 2 => array(self
::URL_PREFERENCES_NAME
, 'String'),
849 3 => array(CRM_Core_Config
::domainID(), 'Integer'),
852 $dao = CRM_Core_DAO
::executeQuery($sql,
858 // trap exceptions as error
862 if (is_a($dao, 'DB_Error')) {
863 if (CRM_Core_Config
::isUpgradeMode()) {
864 // seems like this is a 4.0 -> 4.1 upgrade, so we suppress this error and continue
865 // hack to set the resource base url so that js/ css etc is loaded correctly
867 $params['userFrameworkResourceURL'] = CRM_Utils_File
::addTrailingSlash(CIVICRM_UF_BASEURL
, '/') . str_replace('administrator', '', CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionValue', 'userFrameworkResourceURL', 'value', 'name'));
872 echo "Fatal DB error, exiting, seems like your schema does not have civicrm_setting table\n";
877 while ($dao->fetch()) {
878 $value = self
::getOverride($dao->group_name
, $dao->name
, NULL);
879 if ($value === NULL && $dao->value
) {
880 $value = unserialize($dao->value
);
881 if ($dao->group_name
== self
::DIRECTORY_PREFERENCES_NAME
) {
882 $value = CRM_Utils_File
::absoluteDirectory($value);
885 // CRM-7622: we need to remove the language part
886 $value = CRM_Utils_System
::absoluteURL($value, TRUE);
889 // CRM-10931, If DB doesn't have any value, carry on with any default value thats already available
890 if (!isset($value) && CRM_Utils_Array
::value($dao->name
, $params)) {
891 $value = $params[$dao->name
];
893 $params[$dao->name
] = $value;
896 $config->{$dao->name
} = $value;
902 * Determine what, if any, overrides have been provided
905 * @return mixed, NULL or an overriden value
907 protected static function getOverride($group, $name, $default) {
908 global $civicrm_setting;
909 if ($group && $name && isset($civicrm_setting[$group][$name])) {
910 return $civicrm_setting[$group][$name];