Skip to content

Commit

Permalink
Fix multisite form to work off SettingTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Oct 29, 2018
1 parent cf0789f commit 8fec908
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 50 deletions.
47 changes: 5 additions & 42 deletions CRM/Admin/Form/Preferences/Multisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

}
9 changes: 9 additions & 0 deletions CRM/Admin/Form/SettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ protected function addFieldsDefinedInSettingsMetadata() {
$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(
Expand Down Expand Up @@ -180,6 +185,9 @@ protected function addFieldsDefinedInSettingsMetadata() {
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);
}
Expand Down Expand Up @@ -220,6 +228,7 @@ protected function getQuickFormType($spec) {
'radio' => 'Radio',
'select' => 'Select',
'textarea' => 'Element',
'entity_reference' => 'EntityRef',
];
return $mapping[$spec['html_type']];
}
Expand Down
22 changes: 14 additions & 8 deletions settings/Multisite.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/*

/**
* Settings metadata file
*/

Expand All @@ -41,26 +40,33 @@
'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(
Expand Down

0 comments on commit 8fec908

Please sign in to comment.