From a55c9b35138eac4faff586e01c41df7f3b81f149 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 27 Aug 2018 10:29:34 +1200 Subject: [PATCH] Allow Preferences form to work from settings --- CRM/Admin/Form/Preferences.php | 4 ++++ CRM/Admin/Form/Preferences/Display.php | 10 +++++----- CRM/Admin/Form/SettingTrait.php | 13 +++++++++++++ settings/Core.setting.php | 5 +++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index c379954b73..5bd2e73d34 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -35,6 +35,9 @@ * Base class for settings forms. */ class CRM_Admin_Form_Preferences extends CRM_Core_Form { + + use CRM_Admin_Form_SettingTrait; + protected $_system = FALSE; protected $_contactID = NULL; public $_action = NULL; @@ -85,6 +88,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { $this->_config->contact_id = $this->_contactID; } + $this->addFieldsDefinedInSettingsMetadata(); $settings = Civi::settings(); foreach ($this->_varNames as $groupName => $settingNames) { foreach ($settingNames as $settingName => $options) { diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index f8cb9af818..1ad8357260 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -35,17 +35,17 @@ * This class generates form components for the display preferences. */ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { + + protected $_settings = array( + 'contact_view_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + ); + public function preProcess() { CRM_Utils_System::setTitle(ts('Settings - Display Preferences')); $optionValues = CRM_Activity_BAO_Activity::buildOptions('activity_type_id'); $this->_varNames = array( CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array( - 'contact_view_options' => array( - 'html_type' => 'checkboxes', - 'title' => ts('Viewing Contacts'), - 'weight' => 1, - ), 'contact_smart_group_display' => array( 'html_type' => 'radio', 'title' => ts('Viewing Smart Groups'), diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 734eccc830..ee31f1aa00 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -125,6 +125,19 @@ trait CRM_Admin_Form_SettingTrait { elseif ($add == 'addCheckBox') { $this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, ['  ']); } + elseif ($add == 'addCheckBoxes') { + $options = array_flip($options['values']); + $newOptions = []; + foreach ($options as $key => $val) { + $newOptions[$key] = $val; + } + $this->addCheckBox($setting, + $props['title'], + $newOptions, + NULL, NULL, NULL, NULL, + ['  ', '  ', '
'] + ); + } elseif ($add == 'addChainSelect') { $this->addChainSelect($setting, [ 'label' => ts($props['title']), diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 9d91ed59c0..a7adf37193 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -42,16 +42,17 @@ return array( 'group' => 'core', 'name' => 'contact_view_options', 'type' => 'String', + 'quick_form_type' => 'CheckBoxes', 'html_type' => 'checkboxes', 'pseudoconstant' => array( 'optionGroupName' => 'contact_view_options', ), 'default' => '123456789101113', 'add' => '4.1', - 'title' => 'Viewing Contacts', + 'title' => ts('Viewing Contacts'), 'is_domain' => '1', 'is_contact' => 0, - 'description' => NULL, + 'description' => ts("Select the tabs that should be displayed when viewing a contact record. EXAMPLE: If your organization does not keep track of 'Relationships', then un-check this option to simplify the screen display. Tabs for Contributions, Pledges, Memberships, Events, Grants and Cases are also hidden if the corresponding component is not enabled. Go to Administer > System Settings > Enable Components to modify the components which are available for your site."), 'help_text' => NULL, ), 'contact_edit_options' => array( -- 2.25.1