Allow Preferences form to work from settings
authoreileen <emcnaughton@wikimedia.org>
Sun, 26 Aug 2018 22:29:34 +0000 (10:29 +1200)
committereileen <emcnaughton@wikimedia.org>
Sun, 7 Oct 2018 11:48:46 +0000 (12:48 +0100)
CRM/Admin/Form/Preferences.php
CRM/Admin/Form/Preferences/Display.php
CRM/Admin/Form/SettingTrait.php
settings/Core.setting.php

index c379954b73e2500cd3038cd91dd92f2ae73212ca..5bd2e73d34b4c3b857104e45f5e32d52acadb815 100644 (file)
@@ -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) {
index f8cb9af81828fcdb2e7a8a62ad583efd1991511f..1ad83572600fd2c802eadc6ab8c1c4fc569b9a7d 100644 (file)
  * 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'),
index 734eccc83098fd3eaa1df04efde53e0c6f7e3b11..ee31f1aa005d268765775e5caa02944e00bd1b1e 100644 (file)
@@ -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, ['&nbsp;&nbsp;']);
         }
+        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,
+            ['&nbsp;&nbsp;', '&nbsp;&nbsp;', '<br/>']
+          );
+        }
         elseif ($add == 'addChainSelect') {
           $this->addChainSelect($setting, [
             'label' => ts($props['title']),
index 9d91ed59c03a6a4e1bd8314d98c5cbc2a59bc062..a7adf3719397ac7bc38f3671d69ad59c5e8a3aa3 100644 (file)
@@ -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' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 110\ 111\ 113\ 1',
     '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(