class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
/**
- * Various predefined settings that have been migrated to the setting table
+ * Various predefined settings that have been migrated to the setting table.
*/
const
ADDRESS_STANDARDIZATION_PREFERENCES_NAME = 'Address Standardization Preferences',
}
/**
- * Allow key o be cleared
+ * Allow key o be cleared.
* @param string $cacheKey
*/
public static function flushCache($cacheKey) {
}
/**
- * Retrieve the value of a setting from the DB table
+ * Retrieve the value of a setting from the DB table.
*
* @param string $group
* (required) The group name of the item.
$domainID = NULL
) {
+ $override_group = array();
if (NULL !== ($override = self::getOverride($group, $name, NULL))) {
- return $override;
+ if (isset($name)) {
+ return $override;
+ }
+ else {
+ $override_group = $override;
+ }
}
if (empty($domainID)) {
$domainID = CRM_Core_Config::domainID();
}
$cacheKey = self::inCache($group, $name, $componentID, $contactID, TRUE, $domainID);
+
+ if ($group && !isset($name) && $cacheKey) {
+ // check value against the cache, and unset key if values are different
+ $valueDifference = array_diff($override_group, self::$_cache[$cacheKey]);
+ if (!empty($valueDifference)) {
+ $cacheKey = '';
+ }
+ }
+
if (!$cacheKey) {
$dao = self::dao($group, NULL, $componentID, $contactID, $domainID);
$dao->find();
}
$dao->free();
+ if (!isset($name)) {
+ // merge db and override group values
+ // When no $name is present, the getItem() function should return an array
+ // consisting of the sum of all override settings + all settings present in
+ // the database for the given $group (with the overrides taking precedence,
+ // and applying even if the setting is not defined in the database).
+ //
+ $values = array_merge($values, $override_group);
+ }
+
$cacheKey = self::setCache($values, $group, $componentID, $contactID, $domainID);
}
return $name ? CRM_Utils_Array::value($name, self::$_cache[$cacheKey], $defaultValue) : self::$_cache[$cacheKey];
}
/**
- * Store multiple items in the setting table
+ * Store multiple items in the setting table.
*
* @param array $params
* (required) An api formatted array of keys and values.
- * @param null $domains
+ * @param array $domains Array of domains to get settings for. Default is the current domain
* @param $settingsToReturn
*
- * @domains array an array of domains to get settings for. Default is the current domain
- * @return void
+ * @return array
*/
public static function getItems(&$params, $domains = NULL, $settingsToReturn) {
$originalDomain = CRM_Core_Config::domainID();
}
/**
- * Store an item in the setting table
+ * Store an item in the setting table.
*
* _setItem() is the common logic shared by setItem() and setItems().
*
}
/**
- * Store an item in a setting table
+ * Store an item in a setting table.
*
* _setItem() is the common logic shared by setItem() and setItems().
*
}
/**
- * Load the settings files defined in a series of folders
+ * Load the settings files defined in a series of folders.
* @param array $metaDataFolders
* List of folder paths.
* @return array
}
/**
- * Load up settings metadata from files
+ * Load up settings metadata from files.
*/
public static function loadSettingsMetadata($metaDataFolder) {
$settingMetaData = array();
}
/**
- * Look for any missing settings and convert them from config or load default as appropriate
+ * Look for any missing settings and convert them from config or load default as appropriate.
* This should be run from GenCode & also from upgrades to add any new defaults.
*
* Multisites have often been overlooked in upgrade scripts so can be expected to be missing
if ($group && $name && isset($civicrm_setting[$group][$name])) {
return $civicrm_setting[$group][$name];
}
+ elseif ($group && !isset($name) && isset($civicrm_setting[$group])) {
+ return $civicrm_setting[$group];
+ }
else {
return $default;
}