Skip to content

Commit

Permalink
Rename field "overrideByParent" to "inheritFromCal"
Browse files Browse the repository at this point in the history
  • Loading branch information
markocupic committed Feb 24, 2024
1 parent ef70550 commit 66e76e8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
38 changes: 19 additions & 19 deletions contao/dca/tl_calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
PaletteManipulator::create()
->addLegend('booking_options_legend', 'title_legend', PaletteManipulator::POSITION_AFTER)
->addLegend('event_unsubscribe_legend', 'booking_options_legend', PaletteManipulator::POSITION_AFTER)
->addField(['eventUnsubscribePage', 'calculateTotalFrom', 'eventUnsubscribeNotification', 'eventUnsubscribeNotificationSender'], 'event_unsubscribe_legend', PaletteManipulator::POSITION_APPEND)
->addField(['allowDuplicateEmail', 'bookingState', 'addEscortsToTotal', 'waitingListLimit', 'eventBookingNotification', 'eventBookingNotificationSender'], 'booking_options_legend', PaletteManipulator::POSITION_APPEND)
->addField(['eventUnsubscribePage', 'eventUnsubscribeNotification', 'eventUnsubscribeNotificationSender'], 'event_unsubscribe_legend', PaletteManipulator::POSITION_APPEND)
->addField(['allowDuplicateEmail', 'bookingState', 'calculateTotalFrom', 'addEscortsToTotal', 'waitingListLimit', 'eventBookingNotification', 'eventBookingNotificationSender'], 'booking_options_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_calendar');

$GLOBALS['TL_DCA']['tl_calendar']['fields']['eventUnsubscribePage'] = [
Expand All @@ -36,88 +36,88 @@
'inputType' => 'select',
'options' => [BookingState::STATE_NOT_CONFIRMED, BookingState::STATE_CONFIRMED, BookingState::STATE_UNDEFINED],
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => ['mandatory' => true, 'multiple' => true, 'chosen' => true],
'eval' => ['mandatory' => true, 'multiple' => true, 'chosen' => true, 'tl_class' => 'clr w50'],
'sql' => "varchar(255) NOT NULL default '".serialize([BookingState::STATE_CONFIRMED])."'",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['addEscortsToTotal'] = [
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'eval' => ['isBoolean' => true, 'tl_class' => 'w50 m12 override_event'],
'sql' => "char(1) NOT NULL default ''",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['allowDuplicateEmail'] = [
'eval' => ['isBoolean' => true, 'tl_class' => 'clr m12 override_event'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'eval' => ['isBoolean' => true, 'tl_class' => 'clr m12 override_event'],
'sql' => "char(1) NOT NULL default ''",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['bookingState'] = [
'eval' => ['tl_class' => 'w50 override_event', 'mandatory' => true],
'filter' => true,
'inputType' => 'select',
'options' => BookingState::ALL,
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'search' => true,
'sorting' => true,
'eval' => ['tl_class' => 'clr w50 override_event', 'mandatory' => true],
'sql' => "varchar(64) NOT NULL default '".BookingState::STATE_CONFIRMED."'",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['addEscortsToTotal'] = [
'eval' => ['isBoolean' => true, 'tl_class' => 'clr m12 override_event'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'sql' => "char(1) NOT NULL default ''",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['waitingListLimit'] = [
'eval' => ['rgxp' => 'digit', 'tl_class' => 'clr w50 override_event'],
'exclude' => true,
'inputType' => 'text',
'eval' => ['rgxp' => 'digit', 'tl_class' => 'clr w50 override_event'],
'sql' => "smallint(3) unsigned NOT NULL default '0'",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['eventBookingNotification'] = [
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50 override_event'],
'exclude' => true,
'foreignKey' => 'tl_nc_notification.title',
'inputType' => 'select',
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
'search' => true,
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50 override_event'],
'sql' => 'blob NULL',
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['eventBookingNotificationSender'] = [
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50 override_event'],
'exclude' => true,
'foreignKey' => 'tl_user.name',
'inputType' => 'select',
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
'search' => true,
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50 override_event'],
'sql' => "int(10) unsigned NOT NULL default '0'",
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['eventUnsubscribeNotification'] = [
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50 override_event'],
'exclude' => true,
'foreignKey' => 'tl_nc_notification.title',
'inputType' => 'select',
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
'search' => true,
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50 override_event'],
'sql' => 'blob NULL',
];

// This field is used to override the twin input field in tl_calendar_events
$GLOBALS['TL_DCA']['tl_calendar']['fields']['eventUnsubscribeNotificationSender'] = [
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50 override_event'],
'exclude' => true,
'foreignKey' => 'tl_user.name',
'inputType' => 'select',
'relation' => ['type' => 'hasOne', 'load' => 'lazy'],
'search' => true,
'eval' => ['mandatory' => false, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50 override_event'],
'sql' => "int(10) unsigned NOT NULL default '0'",
];
20 changes: 10 additions & 10 deletions contao/dca/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'activateUnsubscribeNotification';

// Subpalettes
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['enableBookingForm'] = 'overrideByParent,minMembers,maxMembers,maxEscortsPerMember,addEscortsToTotal,bookingStartDate,bookingEndDate,allowDuplicateEmail,bookingState,,activateWaitingList,activateBookingNotification,activateDeregistration';
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['enableBookingForm'] = 'inheritFromCal,minMembers,maxMembers,maxEscortsPerMember,addEscortsToTotal,bookingStartDate,bookingEndDate,allowDuplicateEmail,bookingState,activateWaitingList,activateBookingNotification,activateDeregistration';
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['activateWaitingList'] = 'waitingListLimit';
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['activateBookingNotification'] = 'eventBookingNotification,eventBookingNotificationSender';
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['activateDeregistration'] = 'unsubscribeLimit,unsubscribeLimitTstamp,activateUnsubscribeNotification';
Expand Down Expand Up @@ -87,7 +87,7 @@
'sql' => "char(1) NOT NULL default ''",
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['overrideByParent'] = [
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['inheritFromCal'] = [
'eval' => ['submitOnChange' => true, 'isBoolean' => true, 'tl_class' => 'clr m12'],
'exclude' => true,
'filter' => true,
Expand All @@ -96,15 +96,15 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['allowDuplicateEmail'] = [
'eval' => ['allowOverrideByParent' => true, 'isBoolean' => true, 'tl_class' => 'clr m12'],
'eval' => ['inheritFromCal' => true, 'isBoolean' => true, 'tl_class' => 'clr m12'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'sql' => "char(1) NOT NULL default ''",
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['bookingState'] = [
'eval' => ['allowOverrideByParent' => true, 'tl_class' => 'w50', 'mandatory' => true],
'eval' => ['inheritFromCal' => true, 'tl_class' => 'w50', 'mandatory' => true],
'filter' => true,
'inputType' => 'select',
'options' => BookingState::ALL,
Expand Down Expand Up @@ -158,7 +158,7 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['addEscortsToTotal'] = [
'eval' => ['allowOverrideByParent' => true, 'isBoolean' => true, 'tl_class' => 'clr m12'],
'eval' => ['inheritFromCal' => true, 'isBoolean' => true, 'tl_class' => 'clr m12'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
Expand All @@ -173,7 +173,7 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['waitingListLimit'] = [
'eval' => ['allowOverrideByParent' => true, 'rgxp' => 'digit', 'tl_class' => 'clr w50'],
'eval' => ['inheritFromCal' => true, 'rgxp' => 'digit', 'tl_class' => 'clr w50'],
'exclude' => true,
'inputType' => 'text',
'sql' => "smallint(3) unsigned NOT NULL default '0'",
Expand All @@ -188,7 +188,7 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['eventBookingNotification'] = [
'eval' => ['allowOverrideByParent' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50'],
'eval' => ['inheritFromCal' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50'],
'exclude' => true,
'foreignKey' => 'tl_nc_notification.title',
'inputType' => 'select',
Expand All @@ -198,7 +198,7 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['eventBookingNotificationSender'] = [
'eval' => ['allowOverrideByParent' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'eval' => ['inheritFromCal' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'exclude' => true,
'foreignKey' => 'tl_user.name',
'inputType' => 'select',
Expand Down Expand Up @@ -243,7 +243,7 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['eventUnsubscribeNotification'] = [
'eval' => ['allowOverrideByParent' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50'],
'eval' => ['inheritFromCal' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'multiple' => true, 'tl_class' => 'clr w50'],
'exclude' => true,
'foreignKey' => 'tl_nc_notification.title',
'inputType' => 'select',
Expand All @@ -253,7 +253,7 @@
];

$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['eventUnsubscribeNotificationSender'] = [
'eval' => ['allowOverrideByParent' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'eval' => ['inheritFromCal' => true, 'mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'exclude' => true,
'foreignKey' => 'tl_user.name',
'inputType' => 'select',
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/de/tl_calendar_events.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<source>Booking settings</source>
<target>Buchungseinstellungen</target>
</trans-unit>
<trans-unit id="tl_calendar_events.overrideByParent.0">
<trans-unit id="tl_calendar_events.inheritFromCal.0">
<source>Inherit booking settings from calendar</source>
<target>Buchungseinstellungen von Kalender erben</target>
</trans-unit>
<trans-unit id="tl_calendar_events.overrideByParent.1">
<trans-unit id="tl_calendar_events.inheritFromCal.1">
<source>Inherit booking settings from parent calendar.</source>
<target>Buchungseinstellungen vom übergeordneten Kalender erben.</target>
</trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion contao/languages/en/tl_calendar_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$GLOBALS['TL_LANG']['tl_calendar_events']['booking_options_legend'] = 'Booking settings';

// Fields
$GLOBALS['TL_LANG']['tl_calendar_events']['overrideByParent'] = ['Inherit booking settings from calendar', 'Inherit booking settings from parent calendar.'];
$GLOBALS['TL_LANG']['tl_calendar_events']['inheritFromCal'] = ['Inherit booking settings from calendar', 'Inherit booking settings from parent calendar.'];
$GLOBALS['TL_LANG']['tl_calendar_events']['street'] = ['Street', 'Please add the street.'];
$GLOBALS['TL_LANG']['tl_calendar_events']['postal'] = ['PLZ', 'Please add the postal code.'];
$GLOBALS['TL_LANG']['tl_calendar_events']['city'] = ['Ort', 'Please add the city.'];
Expand Down
4 changes: 2 additions & 2 deletions contao/languages/en/tl_calendar_events.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<trans-unit id="tl_calendar_events.booking_options_legend">
<source>Booking settings</source>
</trans-unit>
<trans-unit id="tl_calendar_events.overrideByParent.0">
<trans-unit id="tl_calendar_events.inheritFromCal.0">
<source>Inherit booking settings from calendar</source>
</trans-unit>
<trans-unit id="tl_calendar_events.overrideByParent.1">
<trans-unit id="tl_calendar_events.inheritFromCal.1">
<source>Inherit booking settings from parent calendar.</source>
</trans-unit>
<trans-unit id="tl_calendar_events.street.0">
Expand Down
8 changes: 4 additions & 4 deletions src/DataContainer/CalendarEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ public function adjustSubPalettes(DataContainer $dc): void
{
$arrRemove = [];

$overrideByParent = (bool) $this->connection->fetchOne('SELECT overrideByParent FROM tl_calendar_events WHERE id = ?', [$dc->id]);
$inheritFromCal = (bool) $this->connection->fetchOne('SELECT inheritFromCal FROM tl_calendar_events WHERE id = ?', [$dc->id]);

if ($overrideByParent) {
if ($inheritFromCal) {
$this->controller->loadDataContainer('tl_calendar_events');
$arrFields = array_keys($GLOBALS['TL_DCA']['tl_calendar_events']['fields']);

foreach ($arrFields as $fieldName) {
$allowOverriding = $GLOBALS['TL_DCA']['tl_calendar_events']['fields'][$fieldName]['eval']['allowOverrideByParent'] ?? false;
$inheritFromCal = $GLOBALS['TL_DCA']['tl_calendar_events']['fields'][$fieldName]['eval']['inheritFromCal'] ?? false;

if (true === $allowOverriding) {
if (true === $inheritFromCal) {
$arrRemove[] = $fieldName;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/EventBooking/Config/EventConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public function get(string $propertyName): mixed

$arrEventFields = $GLOBALS['TL_DCA']['tl_calendar_events']['fields'] ?? [];
$arrCalFields = $GLOBALS['TL_DCA']['tl_calendar']['fields'] ?? [];
$allowOverriding = $arrEventFields[$propertyName]['eval']['allowOverrideByParent'] ?? false;
$inheritFromCal = $arrEventFields[$propertyName]['eval']['inheritFromCal'] ?? false;

if (true === $allowOverriding && !empty($arrCalFields[$propertyName])) {
if (true === $inheritFromCal && !empty($arrCalFields[$propertyName])) {
$calendar = CalendarModel::findByPk($this->get('pid'));

if (null !== $calendar) {
Expand Down

0 comments on commit 66e76e8

Please sign in to comment.