From c89a43b36c680f5e707e604de0f0f045a7945d8b Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Oct 2018 07:55:49 +0100 Subject: [PATCH] Convert Preserve activity tab --- CRM/Admin/Form/Preferences/Display.php | 6 +----- CRM/Admin/Form/SettingTrait.php | 19 +++++++++++-------- settings/Core.setting.php | 14 +++++++------- .../CRM/Admin/Form/Preferences/Display.tpl | 5 ++--- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 1a23425e27..e67401d1f1 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -40,6 +40,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'contact_view_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_smart_group_display' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'preserve_activity_tab_filter' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ); public function preProcess() { @@ -63,11 +64,6 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'title' => ts('Include ICal Invite to Activity Assignees'), 'weight' => 6, ), - 'preserve_activity_tab_filter' => array( - 'html_type' => 'checkbox', - 'title' => ts('Preserve activity filters as a user preference'), - 'weight' => 7, - ), 'contact_ajax_check_similar' => array( 'title' => ts('Check for Similar Contacts'), 'weight' => 8, diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 6a9f7e5f79..5b5364d1e1 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -118,14 +118,16 @@ trait CRM_Admin_Form_SettingTrait { foreach ($settingMetaData as $setting => $props) { $quickFormType = $this->getQuickFormType($props); if (isset($quickFormType)) { + $options = NULL; if (isset($props['pseudoconstant'])) { $options = civicrm_api3('Setting', 'getoptions', [ 'field' => $setting, - ]); + ])['values']; } - else { - $options = NULL; + if ($props['type'] === 'Boolean') { + $options = [$props['title'] => $props['name']]; } + //Load input as readonly whose values are overridden in civicrm.settings.php. if (Civi::settings()->getMandatory($setting)) { $props['html_attributes']['readonly'] = TRUE; @@ -138,18 +140,18 @@ trait CRM_Admin_Form_SettingTrait { $props['html_type'], $setting, ts($props['title']), - ($options !== NULL) ? $options['values'] : CRM_Utils_Array::value('html_attributes', $props, []), + ($options !== NULL) ? $options : CRM_Utils_Array::value('html_attributes', $props, []), ($options !== NULL) ? CRM_Utils_Array::value('html_attributes', $props, []) : NULL ); } elseif ($add == 'addSelect') { - $this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props)); + $this->addElement('select', $setting, ts($props['title']), $options, 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, ['  ']); + $this->addCheckBox($setting, ts($props['title']), $options, NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, ['  ']); } elseif ($add == 'addCheckBoxes') { - $options = array_flip($options['values']); + $options = array_flip($options); $newOptions = []; foreach ($options as $key => $val) { $newOptions[$key] = $val; @@ -170,7 +172,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']), $options['values']); + $this->$add($setting, ts($props['title']), $options); } // Migrate to using an array as easier in smart... $descriptions[$setting] = ts($props['description']); @@ -204,6 +206,7 @@ trait CRM_Admin_Form_SettingTrait { } $mapping = [ 'checkboxes' => 'CheckBoxes', + 'checkbox' => 'CheckBox', 'radio' => 'Radio', ]; return $mapping[$spec['html_type']]; diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 5c279417f7..8e33206275 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -966,28 +966,28 @@ return array( 'group' => 'core', 'name' => 'syncCMSEmail', 'type' => 'Boolean', + 'html_type' => 'YesNo', 'quick_form_type' => 'YesNo', 'default' => 1, 'add' => '4.7', - 'title' => 'Sync CMS Email', + 'title' => ts('Sync CMS Email'), 'is_domain' => 1, 'is_contact' => 0, - 'description' => 'If enabled, then CMS email id will be syncronised with CiviCRM contacts\'s primary email.', + 'description' => ts('If enabled, then CMS email id will be synchronised with CiviCRM contacts\'s primary email.'), 'help_text' => NULL, ), 'preserve_activity_tab_filter' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'preserve_activity_tab_filter', - 'type' => 'String', - 'html_type' => 'Text', + 'type' => 'Boolean', + 'html_type' => 'checkbox', 'default' => '0', 'add' => '4.7', - 'title' => 'Preserve activity filters as a user preference', + 'title' => ts('Preserve activity filters as a user preference'), 'is_domain' => 1, 'is_contact' => 0, - 'description' => 'When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts', - 'help_text' => NULL, + 'description' => ts('When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts.'), ), 'do_not_notify_assignees_for' => array( 'group_name' => 'CiviCRM Preferences', diff --git a/templates/CRM/Admin/Form/Preferences/Display.tpl b/templates/CRM/Admin/Form/Preferences/Display.tpl index 38ea0f0576..8a89f8b626 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.tpl +++ b/templates/CRM/Admin/Form/Preferences/Display.tpl @@ -155,12 +155,11 @@ - {$form.preserve_activity_tab_filter.html} {$form.preserve_activity_tab_filter.label} + {$form.preserve_activity_tab_filter.html}   - {ts}When enabled, any filter settings a user selects on the contact's Activity tab will be remembered as they visit other contacts.{/ts} - + {$settings_fields.preserve_activity_tab_filter.description} -- 2.25.1