X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FForm%2FSetting.php;h=2bc9abe2467647c60692d5e551f6688f6794ac4c;hb=2d277de4d7d51e9b25add7b7ce0d15198ddad3f3;hp=f10182b864a54df53a51ca9b8ec3ca0ed92405d0;hpb=8fc4bac2eadd2deddbc4473bd9ad5641846960d2;p=civicrm-core.git diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index f10182b864..2bc9abe246 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -40,6 +40,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { protected $_settings = array(); + protected $includesReadOnlyFields; + /** * Set default values for the form. * @@ -54,18 +56,9 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { $formMode = TRUE; } - CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults); - - // we can handle all the ones defined in the metadata here. Others to be converted - foreach ($this->_settings as $setting => $group) { - $this->_defaults[$setting] = civicrm_api('setting', 'getvalue', array( - 'version' => 3, - 'name' => $setting, - 'group' => $group, - ) - ); - } + $this->setDefaultsForMetadataDefinedFields(); + // @todo thise should be retrievable from the above function. $this->_defaults['contact_autocomplete_options'] = self::getAutocompleteContactSearch(); $this->_defaults['contact_reference_options'] = self::getAutocompleteContactReference(); $this->_defaults['enableSSL'] = Civi::settings()->get('enableSSL'); @@ -95,71 +88,11 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { ) ); - $descriptions = array(); - $settingMetaData = $this->getSettingsMetaData(); - foreach ($settingMetaData as $setting => $props) { - if (isset($props['quick_form_type'])) { - if (isset($props['pseudoconstant'])) { - $options = civicrm_api3('Setting', 'getoptions', array( - 'field' => $setting, - )); - } - else { - $options = NULL; - } - //Load input as readonly whose values are overridden in civicrm.settings.php. - if (Civi::settings()->getMandatory($setting)) { - $props['html_attributes']['readonly'] = TRUE; - $setStatus = TRUE; - } + $this->addFieldsDefinedInSettingsMetadata(); - $add = 'add' . $props['quick_form_type']; - if ($add == 'addElement') { - $this->$add( - $props['html_type'], - $setting, - ts($props['title']), - ($options !== NULL) ? $options['values'] : CRM_Utils_Array::value('html_attributes', $props, array()), - ($options !== NULL) ? CRM_Utils_Array::value('html_attributes', $props, array()) : NULL - ); - } - elseif ($add == 'addSelect') { - $this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props)); - } - elseif ($add == 'addCheckBox') { - $this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, array('  ')); - } - elseif ($add == 'addChainSelect') { - $this->addChainSelect($setting, array( - 'label' => ts($props['title']), - )); - } - elseif ($add == 'addMonthDay') { - $this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d')); - } - else { - $this->$add($setting, ts($props['title'])); - } - // Migrate to using an array as easier in smart... - $descriptions[$setting] = ts($props['description']); - $this->assign("{$setting}_description", ts($props['description'])); - 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') { - //temp hack - $this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger'); - } - - } - } - if (!empty($setStatus)) { + if ($this->includesReadOnlyFields) { CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', array('expires' => 0)); } - // setting_description should be deprecated - see Mail.tpl for metadata based tpl. - $this->assign('setting_descriptions', $descriptions); - $this->assign('settings_fields', $settingMetaData); } /** @@ -212,7 +145,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { } try { $settings = $this->getSettingsToSetByMetadata($params); - civicrm_api3('setting', 'create', $settings); + $this->saveMetadataDefinedSettings($params); } catch (CiviCRM_API3_Exception $e) { CRM_Core_Session::setStatus($e->getMessage(), ts('Save Failed'), 'error');