From eba92929a27563555a15166fc3426c66bdf8a685 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 29 Oct 2018 19:01:07 +1300 Subject: [PATCH] Fix multisite form to work off SettingTrait --- CRM/Admin/Form/Preferences/Multisite.php | 47 +++--------------------- CRM/Admin/Form/SettingTrait.php | 9 +++++ settings/Multisite.setting.php | 19 ++++++---- 3 files changed, 25 insertions(+), 50 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Multisite.php b/CRM/Admin/Form/Preferences/Multisite.php index 1a8460357e..db9930e1cb 100644 --- a/CRM/Admin/Form/Preferences/Multisite.php +++ b/CRM/Admin/Form/Preferences/Multisite.php @@ -29,53 +29,16 @@ * * @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, + ]; } diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index aab7281f44..219291fa57 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -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']]; } diff --git a/settings/Multisite.setting.php b/settings/Multisite.setting.php index 4a1a3b85a0..c7c6bfb04d 100644 --- a/settings/Multisite.setting.php +++ b/settings/Multisite.setting.php @@ -29,10 +29,9 @@ * * @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( -- 2.25.1