+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
- *
*/
/**
* This class generates form components generic to CiviCRM settings
- *
*/
class CRM_Admin_Form_Setting extends CRM_Core_Form {
/**
* Set default values for the form.
- * default values are retrieved from the database
- *
*
- * @return void
+ * Default values are retrieved from the database.
*/
public function setDefaultValues() {
if (!$this->_defaults) {
$this->_defaults = array();
- $formArray = array('Component', 'Localization');
- $formMode = FALSE;
+ $formArray = array('Component', 'Localization');
+ $formMode = FALSE;
if (in_array($this->_name, $formArray)) {
$formMode = TRUE;
}
CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
$list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options',
- FALSE, FALSE, TRUE, NULL, 'name'
- ));
+ FALSE, FALSE, TRUE, NULL, 'name'
+ ));
$cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options',
- FALSE, FALSE, TRUE, NULL, 'name'
- ));
+ FALSE, FALSE, TRUE, NULL, 'name'
+ ));
$listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_autocomplete_options'
//Set defaults for autocomplete and contact reference options
$this->_defaults['autocompleteContactSearch'] = array(
- '1' => 1) + $autoSearchFields;
+ '1' => 1,
+ ) + $autoSearchFields;
$this->_defaults['autocompleteContactReference'] = array(
- '1' => 1) + $cRSearchFields;
+ '1' => 1,
+ ) + $cRSearchFields;
// we can handle all the ones defined in the metadata here. Others to be converted
- foreach ($this->_settings as $setting => $group){
+ foreach ($this->_settings as $setting => $group) {
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
$this->_defaults[$setting] = civicrm_api('setting', 'getvalue', array(
- 'version' => 3,
- 'name' => $setting,
- 'group' => $group,
- 'default_value' => CRM_Utils_Array::value('default', $settingMetaData['values'][$setting])
+ 'version' => 3,
+ 'name' => $setting,
+ 'group' => $group,
+ 'default_value' => CRM_Utils_Array::value('default', $settingMetaData['values'][$setting]),
)
);
}
}
/**
- * Build the form object
- *
- * @return void
+ * Build the form object.
*/
public function buildQuickForm() {
$session = CRM_Core_Session::singleton();
)
);
- foreach ($this->_settings as $setting => $group){
+ foreach ($this->_settings as $setting => $group) {
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
$props = $settingMetaData['values'][$setting];
- if(isset($props['quick_form_type'])){
+ if (isset($props['quick_form_type'])) {
$add = 'add' . $props['quick_form_type'];
- if($add == 'addElement'){
+ if ($add == 'addElement') {
$this->$add(
$props['html_type'],
$setting,
$props['html_type'] == 'select' ? CRM_Utils_Array::value('html_attributes', $props) : NULL
);
}
- else{
+ else {
$this->$add($setting, ts($props['title']));
}
$this->assign("{$setting}_description", ts($props['description']));
- if($setting == 'max_attachments'){
+ if ($setting == 'max_attachments') {
//temp hack @todo fix to get from metadata
$this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
}
- if($setting == 'maxFileSize'){
+ if ($setting == 'maxFileSize') {
//temp hack
$this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
}
}
/**
- * Process the form submission
- *
- *
- * @return void
+ * Process the form submission.
*/
public function postProcess() {
// store the submitted values in an array
}
/**
+ * Common Process.
+ *
+ * @todo Document what I do.
+ *
* @param array $params
*/
public function commonProcess(&$params) {
// save autocomplete search options
if (!empty($params['autocompleteContactSearch'])) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($params['autocompleteContactSearch'])
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ array_keys($params['autocompleteContactSearch'])
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
CRM_Core_BAO_Setting::setItem($value,
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
// save autocomplete contact reference options
if (!empty($params['autocompleteContactReference'])) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($params['autocompleteContactReference'])
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ array_keys($params['autocompleteContactReference'])
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
CRM_Core_BAO_Setting::setItem($value,
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
// save components to be enabled
if (array_key_exists('enableComponents', $params)) {
- CRM_Core_BAO_Setting::setItem($params['enableComponents'],
- CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
-
- // unset params by emptying the values, so while retrieving we can detect and load from settings table
- // instead of config-backend for backward compatibility. We could use unset() in later releases.
- $params['enableComponents'] = $params['enableComponentIDs'] = array();
+ civicrm_api3('setting', 'create', array(
+ 'enable_components' => $params['enableComponents'],
+ ));
+ unset($params['enableComponents']);
}
// save checksum timeout
}
$settings = array_intersect_key($params, $this->_settings);
$result = civicrm_api('setting', 'create', $settings + array('version' => 3));
- foreach ($settings as $setting => $settingGroup){
+ foreach ($settings as $setting => $settingGroup) {
//@todo array_diff this
unset($params[$setting]);
}
CRM_Core_BAO_ConfigSetting::create($params);
+
+ CRM_Core_Config::clearDBCache();
+ CRM_Utils_System::flushCache();
+ CRM_Core_Resources::singleton()->resetCacheCode();
+
CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success");
}
$configFile = $config->uploadDir . 'Config.IDS.ini';
@unlink($configFile);
}
+
}