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() {
$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'),
$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,
$this->includesReadOnlyFields = TRUE;
}
- $add = 'add' . $props['quick_form_type'];
+ $add = 'add' . $quickFormType;
if ($add == 'addElement') {
$this->$add(
$props['html_type'],
$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']);
$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.
*
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);
}
}
'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',