Fix multisite form to work off SettingTrait
authoreileen <emcnaughton@wikimedia.org>
Mon, 29 Oct 2018 06:01:07 +0000 (19:01 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 29 Oct 2018 11:01:41 +0000 (00:01 +1300)
CRM/Admin/Form/Preferences/Multisite.php
CRM/Admin/Form/SettingTrait.php
settings/Multisite.setting.php

index 1a8460357e0b9abacfe70d8716fe44f8c03ec9be..db9930e1cb16558e3e48d60a6a232710be8f5a8b 100644 (file)
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2018
- * $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
- *
  */
 
 /**
- * This class generates form components for multi site preferences
- *
+ * This class generates form components for multi site preferences.
  */
 class CRM_Admin_Form_Preferences_Multisite extends CRM_Admin_Form_Preferences {
-  public function preProcess() {
-    $msDoc = CRM_Utils_System::docURL2('Multi Site Installation', NULL, NULL, NULL, NULL, "wiki");
-    CRM_Utils_System::setTitle(ts('Multi Site Settings'));
-    $this->_varNames = array(
-      CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array(
-        'is_enabled' => array(
-          'html_type' => 'checkbox',
-          'title' => ts('Enable Multi Site Configuration'),
-          'weight' => 1,
-          'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled') . ' ' . $msDoc,
-        ),
-        /** Remove this checkbox until some one knows what this setting does
-         * 'uniq_email_per_site' => array(
-         * 'html_type' => 'checkbox',
-         * 'title' => ts('Ensure multi sites have a unique email per site'),
-         * 'weight' => 2,
-         * 'description' => NULL,
-         * ),
-         */
-        'domain_group_id' => array(
-          'html_type' => 'entity_reference',
-          'title' => ts('Domain Group'),
-          'weight' => 3,
-          'options' => array('entity' => 'group', 'select' => array('minimumInputLength' => 0)),
-          'description' => ts('Contacts created on this site are added to this group'),
-        ),
-        /** Remove this checkbox until some one knows what this setting does
-         * 'event_price_set_domain_id' => array(
-         * 'html_type' => 'text',
-         * 'title' => ts('Domain for event price sets'),
-         * 'weight' => 4,
-         * 'description' => NULL,
-         * ),
-         */
-      ),
-    );
 
-    parent::preProcess();
-  }
+  protected $_settings = [
+    'is_enabled' => CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
+    'domain_group_id' => CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME,
+  ];
 
 }
index aab7281f44774cd6d8d9740d140869c7d83636b3..219291fa578f02b940a8552829b36b32c6fc7288 100644 (file)
@@ -143,6 +143,11 @@ trait CRM_Admin_Form_SettingTrait {
           $this->includesReadOnlyFields = TRUE;
         }
 
+        if (isset($props['help_link'])) {
+          // Set both the value in this loop & the outer value as we assign both to the template while we deprecate the $descriptions assignment.
+          $settingMetaData[$setting]['description'] = $props['description'] .= ' ' . CRM_Utils_System::docURL2($props['help_link']['page'], NULL, NULL, NULL, NULL, $props['help_link']['resource']);
+
+        }
         $add = 'add' . $quickFormType;
         if ($add == 'addElement') {
           $this->$add(
@@ -180,6 +185,9 @@ trait CRM_Admin_Form_SettingTrait {
         elseif ($add == 'addMonthDay') {
           $this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
         }
+        elseif ($add === 'addEntityRef') {
+          $this->$add($setting, ts($props['title']), $props['entity_reference_options']);
+        }
         else {
           $this->$add($setting, ts($props['title']), $options);
         }
@@ -221,6 +229,7 @@ trait CRM_Admin_Form_SettingTrait {
       'radio' => 'Radio',
       'select' => 'Select',
       'textarea' => 'Element',
+      'entity_reference' => 'EntityRef',
     ];
     return $mapping[$spec['html_type']];
   }
index 4a1a3b85a0006bd5f2aa95ce232bc5067b18532b..c7c6bfb04db65d78fcda38d28c8fe3afe887a681 100644 (file)
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2017
- * $Id$
- *
  */
-/*
+
+/**
  * Settings metadata file
  */
 
@@ -41,26 +40,30 @@ return array(
     'group_name' => 'Multi Site Preferences',
     'group' => 'multisite',
     'name' => 'is_enabled',
-    'title' => 'Multisite Is enabled',
-    'type' => 'Integer',
+    'title' => ts('Enable Multi Site Configuration'),
+    'html_type' => 'checkbox',
+    'type' => 'Boolean',
     'default' => '0',
     'add' => '4.1',
     'is_domain' => 1,
     'is_contact' => 0,
-    'description' => 'Multisite is enabled',
+    'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled'),
+    'help_link' => ['page' => 'Multi Site Installation', 'resource' => 'wiki'],
     'help_text' => NULL,
   ),
   'domain_group_id' => array(
     'group_name' => 'Multi Site Preferences',
     'group' => 'multisite',
     'name' => 'domain_group_id',
-    'title' => 'Multisite Domain Group',
+    'title' => ts('Multisite Domain Group'),
     'type' => 'Integer',
+    'html_type' => 'entity_reference',
+    'entity_reference_options' => ['entity' => 'group', 'select' => array('minimumInputLength' => 0)],
     'default' => '0',
     'add' => '4.1',
     'is_domain' => 1,
     'is_contact' => 0,
-    'description' => NULL,
+    'description' => ts('Contacts created on this site are added to this group'),
     'help_text' => NULL,
   ),
   'event_price_set_domain_id' => array(