| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @param int $domainID
* @param bool $force
*
- * @return boolean true if item is already in cache
- * @static
+ * @return bool
+ * true if item is already in cache
*/
- static function inCache(
+ public static function inCache(
$group,
$name,
$componentID = NULL,
- $contactID = NULL,
- $load = FALSE,
+ $contactID = NULL,
+ $load = FALSE,
$domainID = NULL,
$force = FALSE
) {
return isset(self::$_cache[$cacheKey]) ? $cacheKey : NULL;
}
+
/**
- * Allow key o be cleared
- * @param string $cacheKey
- */
+ * Allow key o be cleared
+ * @param string $cacheKey
+ */
public static function flushCache($cacheKey) {
unset(self::$_cache[$cacheKey]);
$globalCache = CRM_Utils_Cache::singleton();
*
* @return string
*/
- static function setCache(
+ public static function setCache(
$values,
$group,
$componentID = NULL,
*
* @return CRM_Core_DAO_Domain|CRM_Core_DAO_Setting
*/
- static function dao(
+ public static function dao(
$group,
- $name = NULL,
+ $name = NULL,
$componentID = NULL,
- $contactID = NULL,
+ $contactID = NULL,
$domainID = NULL
) {
if (self::isUpgradeFromPreFourOneAlpha1()) {
}
$dao = new CRM_Core_DAO_Setting();
- $dao->group_name = $group;
- $dao->name = $name;
+ $dao->group_name = $group;
+ $dao->name = $name;
$dao->component_id = $componentID;
if (empty($domainID)) {
- $dao->domain_id = CRM_Core_Config::domainID();
+ $dao->domain_id = CRM_Core_Config::domainID();
}
else {
$dao->domain_id = $domainID;
*
* @param int $domainID
*
- * @return mixed The data if present in the setting table, else null
- * @static
+ * @return mixed
+ * The data if present in the setting table, else null
*/
- static function getItem(
+ public static function getItem(
$group,
- $name = NULL,
- $componentID = NULL,
+ $name = NULL,
+ $componentID = NULL,
$defaultValue = NULL,
- $contactID = NULL,
- $domainID = NULL
+ $contactID = NULL,
+ $domainID = NULL
) {
if (NULL !== ($override = self::getOverride($group, $name, NULL))) {
*
* @domains array an array of domains to get settings for. Default is the current domain
* @return void
- * @static
*/
public static function getItems(&$params, $domains = NULL, $settingsToReturn) {
$originalDomain = CRM_Core_Config::domainID();
foreach ($fieldsToGet as $name => $value) {
if (!empty($fields['values'][$name]['prefetch'])) {
if (isset($params['filters']) && isset($params['filters']['prefetch'])
- && $params['filters']['prefetch'] == 0) {
+ && $params['filters']['prefetch'] == 0
+ ) {
// we are filtering out the prefetches from the return array
// so we will skip
continue;
}
- $configKey = CRM_Utils_Array::value('config_key', $fields['values'][$name], $name);
+ $configKey = CRM_Utils_Array::value('config_key', $fields['values'][$name], $name);
if (isset($config->$configKey)) {
$setting = $config->$configKey;
}
}
else {
- $setting =
- CRM_Core_BAO_Setting::getItem(
+ $setting = CRM_Core_BAO_Setting::getItem(
$fields['values'][$name]['group_name'],
$name,
CRM_Utils_Array::value('component_id', $params),
* @param int $domainID
*
* @return void
- * @static
*/
- static function setItem(
+ public static function setItem(
$value,
$group,
$name,
$componentID = NULL,
- $contactID = NULL,
- $createdID = NULL,
- $domainID = NULL
+ $contactID = NULL,
+ $createdID = NULL,
+ $domainID = NULL
) {
$fields = array();
$fieldsToSet = self::validateSettingsInput(array($name => $value), $fields);
* @param int $createdID
* @param int $domainID
*/
- static function _setItem(
+ public static function _setItem(
$metadata,
$value,
$group,
$name,
$componentID = NULL,
- $contactID = NULL,
- $createdID = NULL,
- $domainID = NULL
+ $contactID = NULL,
+ $createdID = NULL,
+ $domainID = NULL
) {
if (empty($domainID)) {
$domainID = CRM_Core_Config::domainID();
* @throws api_Exception
* @domains array an array of domains to get settings for. Default is the current domain
* @return array
- * @static
*/
public static function setItems(&$params, $domains = NULL) {
$originalDomain = CRM_Core_Config::domainID();
* @param bool $createMode
*
* @throws api_Exception
- * @return array $fieldstoset name => value array of the fields to be set (with extraneous removed)
+ * @return array
+ * name => value array of the fields to be set (with extraneous removed)
*/
public static function validateSettingsInput($params, &$fields, $createMode = TRUE) {
$group = CRM_Utils_Array::value('group', $params);
list($name) = array_keys($settingParams);
$getFieldsParams['name'] = $name;
}
- $fields = civicrm_api3('setting','getfields', $getFieldsParams);
+ $fields = civicrm_api3('setting', 'getfields', $getFieldsParams);
$invalidParams = (array_diff_key($settingParams, $fields['values']));
if (!empty($invalidParams)) {
throw new api_Exception(implode(',', array_keys($invalidParams)) . " not valid settings");
*/
public static function validateSetting(&$value, $fieldSpec) {
if ($fieldSpec['type'] == 'String' && is_array($value)) {
- $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,$value) . CRM_Core_DAO::VALUE_SEPARATOR;
+ $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
}
if (empty($fieldSpec['validate_callback'])) {
return TRUE;
}
else {
- list($class,$fn) = explode('::',$fieldSpec['validate_callback']);
- if (!$class::$fn($value,$fieldSpec)) {
+ list($class, $fn) = explode('::', $fieldSpec['validate_callback']);
+ if (!$class::$fn($value, $fieldSpec)) {
throw new api_Exception("validation failed for {$fieldSpec['name']} = $value based on callback {$fieldSpec['validate_callback']}");
}
}
* @param int $domainID
* @param null $profile
*
- * @return array $result - the following information as appropriate for each setting
- * - name
- * - type
- * - default
- * - add (CiviCRM version added)
- * - is_domain
- * - is_contact
- * - description
- * - help_text
+ * @return array
+ * the following information as appropriate for each setting
+ * - name
+ * - type
+ * - default
+ * - add (CiviCRM version added)
+ * - is_domain
+ * - is_contact
+ * - description
+ * - help_text
*/
- static function getSettingSpecification(
+ public static function getSettingSpecification(
$componentID = NULL,
$filters = array(),
$domainID = NULL,
$metaDataFolders = array($civicrm_root . '/settings');
CRM_Utils_Hook::alterSettingsFolders($metaDataFolders);
$settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders);
- CRM_Core_BAO_Cache::setItem($settingsMetadata,'CiviCRM setting Spec', 'All', $componentID);
+ CRM_Core_BAO_Cache::setItem($settingsMetadata, 'CiviCRM setting Spec', 'All', $componentID);
}
$cached = 0;
}
$settings = include $file;
$settingMetaData = array_merge($settingMetaData, $settings);
}
- CRM_Core_BAO_Cache::setItem($settingMetaData,'CiviCRM setting Spec', 'All');
+ CRM_Core_BAO_Cache::setItem($settingMetaData, 'CiviCRM setting Spec', 'All');
return $settingMetaData;
}
*
* @return array
*/
- static function valueOptions(
+ public static function valueOptions(
$group,
$name,
- $system = TRUE,
- $userID = NULL,
- $localize = FALSE,
- $returnField = 'name',
+ $system = TRUE,
+ $userID = NULL,
+ $localize = FALSE,
+ $returnField = 'name',
$returnNameANDLabels = FALSE,
- $condition = NULL
+ $condition = NULL
) {
$optionValue = self::getItem($group, $name);
* @param int $userID
* @param string $keyField
*/
- static function setValueOption(
+ public static function setValueOption(
$group,
$name,
$value,
- $system = TRUE,
- $userID = NULL,
+ $system = TRUE,
+ $userID = NULL,
$keyField = 'name'
) {
if (empty($value)) {
if (!empty($cbValues)) {
$optionValue = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($cbValues)
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ array_keys($cbValues)
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
}
else {
$optionValue = NULL;
OR group_name = %2 )
AND domain_id = %3
";
- $sqlParams = array(1 => array(self::DIRECTORY_PREFERENCES_NAME, 'String'),
+ $sqlParams = array(
+ 1 => array(self::DIRECTORY_PREFERENCES_NAME, 'String'),
2 => array(self::URL_PREFERENCES_NAME, 'String'),
3 => array(CRM_Core_Config::domainID(), 'Integer'),
);
/**
* Civicrm_setting didn't exist before 4.1.alpha1 and this function helps taking decisions during upgrade
*
- * @return boolean
+ * @return bool
*/
public static function isUpgradeFromPreFourOneAlpha1() {
if (CRM_Core_Config::isUpgradeMode()) {
}
return FALSE;
}
+
}