Convert final settings on the Display form
authoreileen <emcnaughton@wikimedia.org>
Wed, 31 Oct 2018 00:13:04 +0000 (13:13 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 31 Oct 2018 00:20:48 +0000 (13:20 +1300)
CRM/Admin/Form/Preferences/Display.php
CRM/Admin/Form/SettingTrait.php
settings/Core.setting.php
templates/CRM/Admin/Form/Preferences/Display.tpl

index b5fc8bc460d82ef0e40165c893ab7dddab3a2aba..ea4745eea70bd4d418fd64ef7b6c6a4e85880197 100644 (file)
@@ -39,80 +39,32 @@ 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,
+    'contact_edit_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'advanced_search_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'user_dashboard_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+    'contact_ajax_check_similar' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'activity_assignee_notification' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'activity_assignee_notification_ics' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+    'do_not_notify_assignees_for' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'preserve_activity_tab_filter' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+    'editor_id' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'ajaxPopupsEnabled' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'display_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'sort_name_format' => 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_edit_options' => array(
-          'html_type' => 'checkboxes',
-          'title' => ts('Editing Contacts'),
-          'weight' => 3,
-        ),
-        'contact_ajax_check_similar' => array(
-          'title' => ts('Check for Similar Contacts'),
-          'weight' => 8,
-          'html_type' => NULL,
-        ),
-        'editor_id' => array(
-          'html_type' => NULL,
-          'weight' => 12,
-        ),
-        'do_not_notify_assignees_for' => array(
-          'html_type' => 'select',
-          'option_values' => $optionValues,
-          'attributes' => array('multiple' => 1, "class" => "huge crm-select2"),
-          'title' => ts('Do not notify assignees for'),
-          'weight' => 14,
-        ),
-      ),
-    );
-
-    parent::preProcess();
-  }
-
-  /**
-   * @return array
-   */
-  public function setDefaultValues() {
-    $defaults = parent::setDefaultValues();
-    parent::cbsDefaultValues($defaults);
-
-    return $defaults;
-  }
-
   /**
    * Build the form object.
    */
   public function buildQuickForm() {
-    $wysiwyg_options = CRM_Core_OptionGroup::values('wysiwyg_editor', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name');
 
     //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $this->assign('invoicing', $invoicing);
-    $extra = array();
 
-    $this->addElement('select', 'editor_id', ts('WYSIWYG Editor'), $wysiwyg_options, $extra);
     $this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));
 
-    $this->addRadio('contact_ajax_check_similar', ts('Check for Similar Contacts'), array(
-      '1' => ts('While Typing'),
-      '0' => ts('When Saving'),
-      '2' => ts('Never'),
-    ));
-
     $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
     $this->assign('editOptions', $editOptions);
 
@@ -151,13 +103,8 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
       CRM_Core_BAO_OptionValue::updateOptionWeights($opGroupId, array_flip($preferenceWeights));
     }
 
-    $this->_config->editor_id = $this->_params['editor_id'];
-
     $this->postProcessCommon();
 
-    // Fixme - shouldn't be needed
-    Civi::settings()->set('contact_ajax_check_similar', $this->_params['contact_ajax_check_similar']);
-
     // If "Configure CKEditor" button was clicked
     if (!empty($this->_params['ckeditor_config'])) {
       // Suppress the "Saved" status message and redirect to the CKEditor Config page
index ab9328af3f3f1baf0753d334753a90f6968b5074..15de133812d06a801556a506598d4474c7a89315 100644 (file)
@@ -127,7 +127,7 @@ trait CRM_Admin_Form_SettingTrait {
     foreach ($settingMetaData as $setting => $props) {
       $quickFormType = $this->getQuickFormType($props);
       if (isset($quickFormType)) {
-        $options = NULL;
+        $options = CRM_Utils_Array::value('options', $props);
         if (isset($props['pseudoconstant'])) {
           $options = civicrm_api3('Setting', 'getoptions', [
             'field' => $setting,
index 47b6ad439c9bf21aee950b3eaeb594330ee21f42..aaf1fcef20fdc8ea02bcadb1ca52c2ff980febc8 100644 (file)
@@ -214,10 +214,13 @@ return array(
     'group' => 'core',
     'name' => 'editor_id',
     'type' => 'String',
-    'html_type' => 'Select',
+    'html_type' => 'select',
     'default' => 'CKEditor',
     'add' => '4.1',
     'title' => ts('Wysiwig Editor'),
+    'pseudoconstant' => array(
+      'optionGroupName' => 'wysiwyg_editor',
+    ),
     'is_domain' => 1,
     'is_contact' => 0,
     'description' => NULL,
@@ -236,6 +239,7 @@ return array(
     'is_contact' => 0,
     'description' => NULL,
     'help_text' => NULL,
+    'options' => ['1' => ts('While Typing'), '0' => ts('When Saving'), '2' => ts('Never')],
   ),
   'ajaxPopupsEnabled' => array(
     'group_name' => 'CiviCRM Preferences',
@@ -996,9 +1000,9 @@ return array(
     'is_domain' => 1,
     'is_contact' => 0,
     'default' => array(),
-    'title' => 'Do not notify assignees for',
-    'help_text' => 'These activity types will be excluded from automated email notifications to assignees.',
-    'html_type' => 'Select',
+    'title' => ts('Do not notify assignees for'),
+    'description' => ts('These activity types will be excluded from automated email notifications to assignees.'),
+    'html_type' => 'select',
     'html_attributes' => array(
       'multiple' => 1,
       'class' => 'huge crm-select2',
index b4cc70561852bd61b2fcd512ec7f57144faaf1e3..ef0fdc4111c466be635d43dfd6e494be17efe8b6 100644 (file)
     </tr>
     <tr class="crm-preferences-display-form-block-activity_assignee_notification">
       <td class="label"></td>
-      <td>{$form.activity_assignee_notification.html} {$form.activity_assignee_notification.label}</td>
+      <td>{$form.activity_assignee_notification.html}</td>
     </tr>
     <tr class="crm-preferences-display-form-block-description">
       <td>&nbsp;</td>
     </tr>
     <tr class="crm-preferences-display-form-block-activity_assignee_notification_ics">
       <td class="label"></td>
-      <td>{$form.activity_assignee_notification_ics.html} {$form.activity_assignee_notification_ics.label}</td>
+      <td>{$form.activity_assignee_notification_ics.html}</td>
     </tr>
     <tr class="crm-preferences-display-form-block-description">
       <td>&nbsp;</td>
         }
 
         // show/hide activity types based on checkbox value
-        $('.crm-preferences-display-form-activity_types').toggle($('#activity_assignee_notification').is(":checked"));
-        $('#activity_assignee_notification').click(function() {
+        $('.crm-preferences-display-form-activity_types').toggle($('#activity_assignee_notification_activity_assignee_notification').is(":checked"));
+        $('#activity_assignee_notification_activity_assignee_notification').click(function() {
           $('.crm-preferences-display-form-activity_types').toggle($(this).is(":checked"));
         });