diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 5af0f3e..2cf9287 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -29,14 +29,14 @@ jobs:
run : amp config:set --mysql_dsn=mysql://root:root@mysql:3306
- name: Build Drupal site
- run: civibuild create drupal-clean --civi-ver 5.24.6 --web-root $GITHUB_WORKSPACE/site
+ run: civibuild create drupal-clean --civi-ver 5.28.3 --cms-ver 7.75 --web-root $GITHUB_WORKSPACE/site
- uses: compucorp/apply-patch@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo: compucorp/civicrm-core
- version: 5.24.6
+ version: 5.28.3
path: site/web/sites/all/modules/civicrm
- uses: actions/checkout@v2
diff --git a/CRM/EventsExtras/Hook/BuildForm/BaseEvent.php b/CRM/EventsExtras/Hook/BuildForm/BaseEvent.php
index 8e966a0..61b71a1 100644
--- a/CRM/EventsExtras/Hook/BuildForm/BaseEvent.php
+++ b/CRM/EventsExtras/Hook/BuildForm/BaseEvent.php
@@ -14,6 +14,16 @@ abstract class CRM_EventsExtras_Hook_BuildForm_BaseEvent {
*/
protected $eventTab;
+ /**
+ * Event tab and class map
+ * @var eventTabAndClassMap
+ */
+ protected $eventTabAndClassMap = [
+ SettingsManager::EVENT_INFO => 'crm-event-manage-eventinfo',
+ SettingsManager::EVENT_FEE => 'crm-event-manage-fee',
+ SettingsManager::EVENT_REGISTRATION => 'crm-event-manage-registration',
+ ];
+
/**
* Constractor for BuildForm class
*
@@ -22,7 +32,6 @@ abstract class CRM_EventsExtras_Hook_BuildForm_BaseEvent {
*/
protected function __construct($eventTab) {
$this->eventTab = $eventTab;
- $this->addEventTabTemplate();
}
/**
@@ -49,32 +58,34 @@ protected function shouldHandle($formName, $formClass) {
}
/**
- * fuction to hide fields based on settings
+ * Hide fields on the Event Forms
*
- * @param array $form
+ * @param array $fieldIds
*
*/
- protected function hideField(&$form) {
- $configFields = SettingsManager::getConfigFields($this->eventTab);
- $settingsValue = SettingsManager::getSettingsValue();
- $hiddenFields = [];
-
- foreach ($configFields as $config) {
- $configNameExists = isset($settingsValue[$config['name']]);
- $configNameIsZero = $settingsValue[$config['name']] == 0;
- $cssClassExists = array_key_exists('css_class', $config['extra_attributes']);
- if ($configNameExists && $configNameIsZero && $cssClassExists) {
- $hiddenFields[] = $config['extra_attributes']['css_class'];
- }
+ protected function hideFields($fieldIds) {
+ $selectors = [];
+ foreach ($fieldIds as $fieldId) {
+ $class = $this->eventTabAndClassMap[$this->eventTab] . '-form-block-' . $fieldId;
+ $selectors[] = "tr[class={$class}]";
}
- $form->assign('hiddenCssClasses', $hiddenFields);
+ $selectors = implode(', ', $selectors);
+
+ $this->hideElementBySelector($selectors);
}
- private function addEventTabTemplate() {
- $templatePath = E::path() . '/templates/CRM/EventsExtras/Form/EventTabs.tpl';
- CRM_Core_Region::instance('page-body')->add([
- 'template' => "{$templatePath}",
- ]);
+ /**
+ * Hide elements by CSS selector
+ *
+ * @param string $selector
+ *
+ */
+ protected function hideElementBySelector($selector) {
+ CRM_Core_Resources::singleton()->addScript(
+ "CRM.$(function($) {
+ $('{$selector}').hide();
+ });
+ ");
}
}
diff --git a/CRM/EventsExtras/Hook/BuildForm/EventFee.php b/CRM/EventsExtras/Hook/BuildForm/EventFee.php
index 80f5445..0e8ece1 100644
--- a/CRM/EventsExtras/Hook/BuildForm/EventFee.php
+++ b/CRM/EventsExtras/Hook/BuildForm/EventFee.php
@@ -24,7 +24,6 @@ public function handle($formName, &$form) {
if (!$this->shouldHandle($formName, CRM_Event_Form_ManageEvent_Fee::class)) {
return;
}
- $this->hideField($form);
$this->buildForm($formName, $form);
}
@@ -34,15 +33,46 @@ private function buildForm($formName, &$form) {
private function setDefaults(&$form) {
$defaults = [];
- $paymentProcessor = SettingsManager::SETTING_FIELDS['PAYMENT_PROCESSOR_SELECTION'];
+ $fieldIdsToHide = [];
+
+ $showPaymentProcessor = SettingsManager::SETTING_FIELDS['PAYMENT_PROCESSOR_SELECTION'];
$paymentProcessorDefault = SettingsManager::SETTING_FIELDS['PAYMENT_PROCESSOR_SELECTION_DEFAULT'];
- $settings = [$paymentProcessor, $paymentProcessorDefault];
+ $settings = [$showPaymentProcessor, $paymentProcessorDefault];
$settingValues = SettingsManager::getSettingsValue($settings);
- if ($settingValues[$paymentProcessor] == 0) {
+ if ($settingValues[$showPaymentProcessor] == 0) {
$defaultSettingString = implode(CRM_Core_DAO::VALUE_SEPARATOR, $settingValues[$paymentProcessorDefault]);
$paymentProcessorDefaultValue = (array_fill_keys(explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaultSettingString), '1'));
$defaults['payment_processor'] = $paymentProcessorDefaultValue;
+ $fieldIdsToHide[] = 'payment_processor';
}
+
+ $showCurrency = SettingsManager::SETTING_FIELDS['CURRENCY'];
+ $currencyDefault = SettingsManager::SETTING_FIELDS['CURRENCY_DEFAULT'];
+ $settings = [$showCurrency, $currencyDefault];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showCurrency] == 0) {
+ $defaults['currency'] = $settingValues[$currencyDefault];
+ $fieldIdsToHide[] = 'currency';
+ }
+
+ $showPayLater = SettingsManager::SETTING_FIELDS['PAY_LATER_OPTION'];
+ $payLaterDefault = SettingsManager::SETTING_FIELDS['PAY_LATER_OPTION_DEFAULT'];
+ $payLaterLabel = SettingsManager::SETTING_FIELDS['PAY_LATER_OPTION_DEFAULT_LABEL'];
+ $payLaterInstruction = SettingsManager::SETTING_FIELDS['PAY_LATER_OPTION_DEFAULT_LABEL_INSTRUCTION'];
+ $payLaterBillingAddress = SettingsManager::SETTING_FIELDS['PAY_LATER_OPTION_DEFAULT_BILLING_ADDRESS'];
+ $settings = [$showPayLater, $payLaterDefault, $payLaterLabel, $payLaterInstruction, $payLaterBillingAddress];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showPayLater] == 0) {
+ $defaults['is_pay_later'] = $settingValues[$payLaterDefault];
+ $defaults['pay_later_text'] = $settingValues[$payLaterLabel];
+ $defaults['pay_later_receipt'] = $settingValues[$payLaterInstruction];
+ $defaults['is_billing_required'] = $settingValues[$payLaterBillingAddress];
+ $fieldIdsToHide[] = 'is_pay_later';
+
+ $this->hideElementBySelector('#payLaterOptions');
+ }
+
+ $this->hideFields($fieldIdsToHide);
$form->setDefaults($defaults);
}
diff --git a/CRM/EventsExtras/Hook/BuildForm/EventInfo.php b/CRM/EventsExtras/Hook/BuildForm/EventInfo.php
index 236077f..5114872 100644
--- a/CRM/EventsExtras/Hook/BuildForm/EventInfo.php
+++ b/CRM/EventsExtras/Hook/BuildForm/EventInfo.php
@@ -24,7 +24,6 @@ public function handle($formName, &$form) {
if (!$this->shouldHandle($formName, CRM_Event_Form_ManageEvent_EventInfo::class)) {
return;
}
- $this->hideField($form);
$this->buildForm($formName, $form);
}
@@ -40,13 +39,45 @@ private function buildForm($formName, &$form) {
*/
private function setDefaults(&$form) {
$defaults = [];
- $role = SettingsManager::SETTING_FIELDS['ROLES'];
+ $fieldIdsToHide = [];
+
+ $showRoles = SettingsManager::SETTING_FIELDS['ROLES'];
$roleDefault = SettingsManager::SETTING_FIELDS['ROLES_DEFAULT'];
- $settings = [$role, $roleDefault];
+ $settings = [$showRoles, $roleDefault];
$settingValues = SettingsManager::getSettingsValue($settings);
- if ($settingValues[$role] == 0) {
+ if ($settingValues[$showRoles] == 0) {
$defaults['default_role_id'] = $settingValues[$roleDefault];
+ $fieldIdsToHide[] = 'default_role_id';
+ }
+
+ $showParticipantListing = SettingsManager::SETTING_FIELDS['PARTICIPANT_LISTING'];
+ $participantListingDefault = SettingsManager::SETTING_FIELDS['PARTICIPANT_LISTING_DEFAULT'];
+ $settings = [$showParticipantListing, $participantListingDefault];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showParticipantListing] == 0) {
+ $defaults['participant_listing_id'] = $settingValues[$participantListingDefault];
+ $fieldIdsToHide[] = 'participant_listing_id';
}
+
+ $showIncludeMap = SettingsManager::SETTING_FIELDS['INCLUDE_MAP_LOCATION_EVENT'];
+ $includeMapDefault = SettingsManager::SETTING_FIELDS['INCLUDE_MAP_LOCATION_EVENT_DEFAULT'];
+ $settings = [$showIncludeMap, $includeMapDefault];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showIncludeMap] == 0) {
+ $defaults['is_map'] = $settingValues[$includeMapDefault];
+ $fieldIdsToHide[] = 'is_map';
+ }
+
+ $showPublicEvent = SettingsManager::SETTING_FIELDS['INCLUDE_MAP_PUBLIC_EVENT'];
+ $publicEventDefault = SettingsManager::SETTING_FIELDS['INCLUDE_MAP_PUBLIC_EVENT_DEFAULT'];
+ $settings = [$showPublicEvent, $publicEventDefault];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showPublicEvent] == 0) {
+ $defaults['is_public'] = $settingValues[$publicEventDefault];
+ $fieldIdsToHide[] = 'is_public';
+ }
+
+ $this->hideFields($fieldIdsToHide);
$form->setDefaults($defaults);
}
diff --git a/CRM/EventsExtras/Hook/BuildForm/EventRegistration.php b/CRM/EventsExtras/Hook/BuildForm/EventRegistration.php
index cfe051c..12dc5d4 100644
--- a/CRM/EventsExtras/Hook/BuildForm/EventRegistration.php
+++ b/CRM/EventsExtras/Hook/BuildForm/EventRegistration.php
@@ -24,7 +24,61 @@ public function handle($formName, &$form) {
if (!$this->shouldHandle($formName, CRM_Event_Form_ManageEvent_Registration::class)) {
return;
}
- $this->hideField($form);
+ $this->buildForm($formName, $form);
+ }
+
+ private function buildForm($formName, &$form) {
+ $this->setDefaults($form);
+ }
+
+ private function setDefaults(&$form) {
+ $defaults = [];
+ $fieldIdsToHide = [];
+
+ $showPendingParticipantExpiration = SettingsManager::SETTING_FIELDS['PENDING_PARTICIPANT_EXPIRATION'];
+ $pendingParticipantExpirationDefault = SettingsManager::SETTING_FIELDS['PENDING_PARTICIPANT_EXPIRATION_DEFAULT'];
+ $settings = [$showPendingParticipantExpiration, $pendingParticipantExpirationDefault];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showPendingParticipantExpiration] == 0) {
+ $defaults['expiration_time'] = $settingValues[$pendingParticipantExpirationDefault];
+ $fieldIdsToHide[] = 'expiration_time';
+ }
+
+ $showAllowSelfServiceAction = SettingsManager::SETTING_FIELDS['ALLOW_SELF_SERVICE'];
+ $allowSelfServiceActionDefault = SettingsManager::SETTING_FIELDS['ALLOW_SELF_SERVICE_DEFAULT'];
+ $timeLimit = SettingsManager::SETTING_FIELDS['ALLOW_SELF_SERVICE_DEFAULT_TIME_LIMIT'];
+ $settings = [$showAllowSelfServiceAction, $allowSelfServiceActionDefault, $timeLimit];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showAllowSelfServiceAction] == 0) {
+ $defaults['allow_selfcancelxfer'] = $settingValues[$allowSelfServiceActionDefault];
+ $defaults['selfcancelxfer_time'] = $settingValues[$timeLimit];
+
+ // @note allow_selfcancelxfer's parent tr in civicrm/templates/CRM/Event/Form/ManageEvent/Registration.tpl
+ // has a missing 'allow' i.e. "crm-event-manage-registration-form-block-selfcancelxfer" (CiviCRM bug)
+ $fieldIdsToHide[] = 'selfcancelxfer';
+ $fieldIdsToHide[] = 'selfcancelxfer_time';
+ }
+
+ $showRegisterMultipleParticipants = SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS'];
+ $registerMultipleParticipantsDefault = SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS_DEFAULT'];
+ $maximumParticipant = SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS_DEFAULT_MAXIMUM_PARTICIPANT'];
+ $allowSameParticipantEmailsDefault = SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS_ALLOW_SAME_PARTICIPANT_EMAILS_DEFAULT'];
+ $settings = [$showRegisterMultipleParticipants, $registerMultipleParticipantsDefault, $maximumParticipant, $allowSameParticipantEmailsDefault];
+ $settingValues = SettingsManager::getSettingsValue($settings);
+ if ($settingValues[$showRegisterMultipleParticipants] == 0) {
+ $defaults['is_multiple_registrations'] = $settingValues[$registerMultipleParticipantsDefault];
+ $defaults['max_additional_participants'] = $settingValues[$maximumParticipant];
+ $defaults['allow_same_participant_emails'] = $settingValues[$allowSameParticipantEmailsDefault];
+ $fieldIdsToHide[] = 'is_multiple_registrations';
+
+ // @note max_additional_participants's parent tr in civicrm/templates/CRM/Event/Form/ManageEvent/Registration.tpl
+ // has a 'maximum' in its name instead of max i.e. "crm-event-manage-registration-form-block-maximum_additional_participants" (CiviCRM bug)
+ $fieldIdsToHide[] = 'maximum_additional_participants';
+ $fieldIdsToHide[] = 'allow_same_participant_emails';
+ }
+
+ $this->hideFields($fieldIdsToHide);
+ $form->setDefaults($defaults);
}
}
diff --git a/CRM/EventsExtras/SettingsManager.php b/CRM/EventsExtras/SettingsManager.php
index 2cc976f..517b59a 100644
--- a/CRM/EventsExtras/SettingsManager.php
+++ b/CRM/EventsExtras/SettingsManager.php
@@ -45,6 +45,7 @@ class CRM_EventsExtras_SettingsManager {
'REGISTER_MULTIPLE_PARTICIPANTS' => 'eventsextras_register_multiple_participants',
'REGISTER_MULTIPLE_PARTICIPANTS_DEFAULT' => 'eventsextras_register_multiple_participants_default',
'REGISTER_MULTIPLE_PARTICIPANTS_DEFAULT_MAXIMUM_PARTICIPANT' => 'eventsextras_register_multiple_participants_default_maximum_participant',
+ 'REGISTER_MULTIPLE_PARTICIPANTS_ALLOW_SAME_PARTICIPANT_EMAILS_DEFAULT' => 'eventsextras_register_multiple_participants_allow_same_participant_emails_default',
];
/**
diff --git a/CRM/EventsExtras/Test/Fabricator/Base.php b/CRM/EventsExtras/Test/Fabricator/Base.php
new file mode 100644
index 0000000..a93279e
--- /dev/null
+++ b/CRM/EventsExtras/Test/Fabricator/Base.php
@@ -0,0 +1,42 @@
+ 'Event Sample' ,
+ ];
+
+ /**
+ * Fabricates an event with the given parameters.
+ *
+ * @param array $params
+ *
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ */
+ public static function fabricate(array $params = []) {
+ $startDate = new DateTime();
+
+ $eventType = self::createEventType();
+ $eventTypeId = $eventType['value'];
+
+ $defaultParams = array_merge(static::$defaultParams, [
+ 'start_date' => $startDate->format('Ymd'),
+ 'event_type_id' => $eventTypeId,
+ ]);
+
+ $params = array_merge($defaultParams, $params);
+
+ return parent::fabricate($params);
+ }
+
+ private static function createEventType() {
+ $result = civicrm_api3('OptionValue', 'create', [
+ 'option_group_id' => 'event_type',
+ 'name' => 'Conference',
+ ]);
+ $eventType = array_shift($result['values']);
+
+ return $eventType;
+ }
+
+}
diff --git a/CRM/EventsExtras/Test/Fabricator/Setting.php b/CRM/EventsExtras/Test/Fabricator/Setting.php
index fca379f..9685ef5 100644
--- a/CRM/EventsExtras/Test/Fabricator/Setting.php
+++ b/CRM/EventsExtras/Test/Fabricator/Setting.php
@@ -1,7 +1,7 @@
'',
'extra_attributes' => [
'section' => SettingsManager::EVENT_TAB,
- 'css_class' => '',
],
],
'eventsextras_tell_friend_tab' => [
@@ -37,7 +36,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_TAB,
- 'css_class' => '',
],
],
'eventsextras_pcp_tab' => [
@@ -54,7 +52,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_TAB,
- 'css_class' => '',
],
],
'eventsextras_roles' => [
@@ -71,7 +68,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_INFO,
- 'css_class' => 'crm-event-manage-eventinfo-form-block-default_role_id',
],
],
'eventsextras_participant_listing' => [
@@ -88,7 +84,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_INFO,
- 'css_class' => 'crm-event-manage-eventinfo-form-block-participant_listing_id',
],
],
'eventsextras_event_summary' => [
@@ -105,7 +100,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_INFO,
- 'css_class' => 'crm-event-manage-eventinfo-form-block-summary',
],
],
'eventsextras_event_description' => [
@@ -122,7 +116,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_INFO,
- 'css_class' => 'crm-event-manage-eventinfo-form-block-description',
],
],
'eventsextras_include_map_event_location' => [
@@ -139,7 +132,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_INFO,
- 'css_class' => 'crm-event-manage-eventinfo-form-block-is_map',
],
],
'eventsextras_public_event' => [
@@ -156,7 +148,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_INFO,
- 'css_class' => 'crm-event-manage-eventinfo-form-block-is_public',
],
],
'eventsextras_currency' => [
@@ -173,7 +164,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_FEE,
- 'css_class' => 'crm-event-manage-fee-form-block-currency',
],
],
'eventsextras_enable_pay_later_option' => [
@@ -190,7 +180,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_FEE,
- 'css_class' => 'crm-event-manage-fee-form-block-is_pay_later',
],
],
'eventsextras_payment_processor_selection' => [
@@ -207,7 +196,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_FEE,
- 'css_class' => 'crm-event-manage-fee-form-block-payment_processor',
],
],
'eventsextras_pending_participant_expiration' => [
@@ -224,7 +212,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_REGISTRATION,
- 'css_class' => 'crm-event-manage-registration-form-block-expiration_time',
],
],
'eventsextras_allow_self_service' => [
@@ -241,7 +228,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_REGISTRATION,
- 'css_class' => 'crm-event-manage-registration-form-block-selfcancelxfer',
],
],
'eventsextras_register_multiple_participants' => [
@@ -258,7 +244,6 @@
'help_text' => '',
'extra_attributes' => [
'section' => SettingsManager::EVENT_REGISTRATION,
- 'css_class' => 'crm-event-manage-registration-form-block-is_multiple_registrations',
],
],
];
diff --git a/settings/EventsExtrasDefault.setting.php b/settings/EventsExtrasDefault.setting.php
index 8561b57..4a8c89e 100644
--- a/settings/EventsExtrasDefault.setting.php
+++ b/settings/EventsExtrasDefault.setting.php
@@ -319,4 +319,23 @@
'event_form_element_name' => 'max_additional_participants',
],
],
+ 'eventsextras_register_multiple_participants_allow_same_participant_emails_default' => [
+ 'name' => 'eventsextras_register_multiple_participants_allow_same_participant_emails_default',
+ 'title' => ts('Set Default Same email address? '),
+ 'type' => 'Integer',
+ 'quick_form_type' => 'Checkbox',
+ 'default' => '',
+ 'html_type' => 'checkbox',
+ 'add' => '1.0',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'is_help' => TRUE,
+ 'description' => ts(''),
+ 'help_text' => '',
+ 'extra_attributes' => [
+ 'section' => SettingsManager::EVENT_REGISTRATION,
+ 'parent_setting' => SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS'],
+ 'event_form_element_name' => 'allow_same_participant_emails',
+ ],
+ ],
];
diff --git a/templates/CRM/EventsExtras/Form/EventTabs.tpl b/templates/CRM/EventsExtras/Form/EventTabs.tpl
deleted file mode 100644
index 2967fe9..0000000
--- a/templates/CRM/EventsExtras/Form/EventTabs.tpl
+++ /dev/null
@@ -1,39 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
-*}
-{* Hide Info in Event Tabs based on Events Extras Settings. *}
- {literal}
-
- {/literal}
\ No newline at end of file
diff --git a/templates/CRM/EventsExtras/Form/Settings.hlp b/templates/CRM/EventsExtras/Form/Settings.hlp
index c6bb3a9..8f795b9 100644
--- a/templates/CRM/EventsExtras/Form/Settings.hlp
+++ b/templates/CRM/EventsExtras/Form/Settings.hlp
@@ -68,10 +68,16 @@
{/ts}
{/htxt}
-{htxt id="eventsextras_register_multiple_participants_default_maxinum_participant"}
+{htxt id="eventsextras_register_multiple_participants_default_maximum_participant"}
{ts}
Limit the number of additional participants that can be registered in a single booking.
Eg: if you choose '2' then the lead booker can bring 2 guests;
there would be a limit of 3 participants in total per booking.
{/ts}
{/htxt}
+
+{htxt id="eventsextras_register_multiple_participants_allow_same_participant_emails_default"}
+ {ts}
+ Check this box to allow a user to register multiple participants using the same email address. Alternatively, if you want additional participants to be registered without requiring an email address to be entered for each person - check the "Register multiple participants" option, AND include a profile in this registration form which includes First Name and Last Name fields.
+ {/ts}
+{/htxt}
diff --git a/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventInfoTest.php b/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventInfoTest.php
index e472438..7e2415b 100644
--- a/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventInfoTest.php
+++ b/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventInfoTest.php
@@ -33,7 +33,7 @@ public function testSetDefault() {
$eventInfoFormHook = new CRM_EventsExtras_Hook_BuildForm_EventInfo();
$eventInfoFormHook->handle('CRM_Event_Form_ManageEvent_EventInfo', $eventInfoForm);
- $this->assertEquals(3, $eventInfoForm->getElementValue('default_role_id')[0]);
+ $this->assertEquals(3, $eventInfoForm->_defaultValues['default_role_id']);
}
}
diff --git a/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventRegistrationTest.php b/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventRegistrationTest.php
new file mode 100644
index 0000000..171b313
--- /dev/null
+++ b/tests/phpunit/CRM/EventsExtras/Hook/BuildForm/EventRegistrationTest.php
@@ -0,0 +1,49 @@
+eventRegistrationForm = new CRM_Event_Form_ManageEvent_Registration();
+ $this->eventRegistrationForm->controller = $formController;
+ $this->eventRegistrationForm->set('id', $event['id']);
+ $this->eventRegistrationForm->buildForm();
+ }
+
+ public function testSetDefault() {
+ SettingFabricator::fabricate([
+ SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS'] => 0,
+ SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS_DEFAULT'] => 1,
+ SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS_DEFAULT_MAXIMUM_PARTICIPANT'] => 5,
+ SettingsManager::SETTING_FIELDS['REGISTER_MULTIPLE_PARTICIPANTS_ALLOW_SAME_PARTICIPANT_EMAILS_DEFAULT'] => 1,
+ ]);
+
+ $eventRegistrationFormHook = new CRM_EventsExtras_Hook_BuildForm_EventRegistration();
+ $eventRegistrationFormHook->handle('CRM_Event_Form_ManageEvent_Registration', $this->eventRegistrationForm);
+
+ $this->assertEquals(1, $this->eventRegistrationForm->_defaultValues['is_multiple_registrations']);
+ $this->assertEquals(5, $this->eventRegistrationForm->_defaultValues['max_additional_participants']);
+
+ $this->assertEquals(1, $this->eventRegistrationForm->_defaultValues['allow_same_participant_emails']);
+ }
+
+}
diff --git a/tests/phpunit/CRM/EventsExtras/SettingsManagerTest.php b/tests/phpunit/CRM/EventsExtras/SettingsManagerTest.php
index 2b420f6..2e25bc2 100644
--- a/tests/phpunit/CRM/EventsExtras/SettingsManagerTest.php
+++ b/tests/phpunit/CRM/EventsExtras/SettingsManagerTest.php
@@ -66,7 +66,7 @@ public function testGetConfigFields() {
$this->assertEquals(9, count($configFields));
$configFields = $settingsManager->getConfigFields(SettingsManager::EVENT_REGISTRATION);
$this->assertNotEmpty($configFields);
- $this->assertEquals(8, count($configFields));
+ $this->assertEquals(9, count($configFields));
}
}