Commit c5af8245 authored by eileen's avatar eileen

Convert 'Viewing Smart Groups' on admin display preferences to use metadata.

This has no functional impact - cleanup only
parent 25a057dd
......@@ -38,6 +38,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
protected $_settings = array(
'contact_view_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_smart_group_display' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
);
public function preProcess() {
......@@ -46,11 +47,6 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
$this->_varNames = array(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
'contact_smart_group_display' => array(
'html_type' => 'radio',
'title' => ts('Viewing Smart Groups'),
'weight' => 2,
),
'contact_edit_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Editing Contacts'),
......
......@@ -116,7 +116,8 @@ trait CRM_Admin_Form_SettingTrait {
$settingMetaData = $this->getSettingsMetaData();
$descriptions = [];
foreach ($settingMetaData as $setting => $props) {
if (isset($props['quick_form_type'])) {
$quickFormType = $this->getQuickFormType($props);
if (isset($quickFormType)) {
if (isset($props['pseudoconstant'])) {
$options = civicrm_api3('Setting', 'getoptions', [
'field' => $setting,
......@@ -131,7 +132,7 @@ trait CRM_Admin_Form_SettingTrait {
$this->includesReadOnlyFields = TRUE;
}
$add = 'add' . $props['quick_form_type'];
$add = 'add' . $quickFormType;
if ($add == 'addElement') {
$this->$add(
$props['html_type'],
......@@ -169,7 +170,7 @@ trait CRM_Admin_Form_SettingTrait {
$this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
}
else {
$this->$add($setting, ts($props['title']));
$this->$add($setting, ts($props['title']), $options['values']);
}
// Migrate to using an array as easier in smart...
$descriptions[$setting] = ts($props['description']);
......@@ -190,7 +191,23 @@ trait CRM_Admin_Form_SettingTrait {
$this->assign('settings_fields', $settingMetaData);
}
/**
* Get the quickform type for the given html type.
*
* @param array $spec
*
* @return string
*/
protected function getQuickFormType($spec) {
if (isset($spec['quick_form_type'])) {
return $spec['quick_form_type'];
}
$mapping = [
'checkboxes' => 'CheckBoxes',
'radio' => 'Radio',
];
return $mapping[$spec['html_type']];
}
/**
* Get the defaults for all fields defined in the metadata.
*
......@@ -204,7 +221,7 @@ trait CRM_Admin_Form_SettingTrait {
if (!empty($spec['serialize'])) {
$this->_defaults[$setting] = CRM_Core_DAO::unSerializeField($this->_defaults[$setting], $spec['serialize']);
}
if ($spec['quick_form_type'] === 'CheckBoxes') {
if ($this->getQuickFormType($spec) === 'CheckBoxes') {
$this->_defaults[$setting] = array_fill_keys($this->_defaults[$setting], 1);
}
}
......
......@@ -324,8 +324,11 @@ return array(
'title' => ts('Viewing Smart Groups'),
'is_domain' => 1,
'is_contact' => 0,
'description' => NULL,
'description' => ts('Controls display of the smart groups that a contact is part of in each contact\'s "Groups" tab. "Show on Demand" provides the best performance, and is recommended for most sites.'),
'help_text' => NULL,
'pseudoconstant' => array(
'optionGroupName' => 'contact_smart_group_display',
),
),
'smart_group_cache_refresh_mode' => array(
'group_name' => 'CiviCRM Preferences',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment