Skip to content

Commit aa3fcb5

Browse files
committed
Merge branch 'develop'
2 parents 384ae22 + 12838e5 commit aa3fcb5

15 files changed

+157
-10
lines changed

dca/tl_calendar.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
*/
2121
$GLOBALS['TL_DCA']['tl_calendar']['palettes']['__selector__'][] = 'subscription_enable';
2222
$GLOBALS['TL_DCA']['tl_calendar']['palettes']['__selector__'][] = 'subscription_waitingList';
23+
$GLOBALS['TL_DCA']['tl_calendar']['palettes']['__selector__'][] = 'subscription_memberGroupsLimit';
2324
$GLOBALS['TL_DCA']['tl_calendar']['palettes']['__selector__'][] = 'subscription_reminders';
2425

2526
\Haste\Dca\PaletteManipulator::create()
2627
->addLegend('subscription_legend', 'title_legend', \Haste\Dca\PaletteManipulator::POSITION_AFTER, true)
2728
->addField('subscription_enable', 'subscription_legend', \Haste\Dca\PaletteManipulator::POSITION_APPEND)
2829
->applyToPalette('default', 'tl_calendar');
2930

30-
$GLOBALS['TL_DCA']['tl_calendar']['subpalettes']['subscription_enable'] = 'subscription_types,subscription_maximum,subscription_subscribeEndTime,subscription_unsubscribeEndTime,subscription_waitingList,subscription_reminders,subscription_unsubscribeLinkPage';
31+
$GLOBALS['TL_DCA']['tl_calendar']['subpalettes']['subscription_enable'] = 'subscription_types,subscription_maximum,subscription_subscribeEndTime,subscription_unsubscribeEndTime,subscription_waitingList,subscription_memberGroupsLimit,subscription_reminders,subscription_unsubscribeLinkPage';
3132
$GLOBALS['TL_DCA']['tl_calendar']['subpalettes']['subscription_waitingList'] = 'subscription_waitingListLimit';
33+
$GLOBALS['TL_DCA']['tl_calendar']['subpalettes']['subscription_memberGroupsLimit'] = 'subscription_memberGroups';
3234
$GLOBALS['TL_DCA']['tl_calendar']['subpalettes']['subscription_reminders'] = 'subscription_time,subscription_days,subscription_notification';
3335

3436
/**
@@ -49,6 +51,8 @@
4951
$GLOBALS['TL_DCA']['tl_calendar']['fields']['subscription_unsubscribeEndTime'] = &$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_unsubscribeEndTime'];
5052
$GLOBALS['TL_DCA']['tl_calendar']['fields']['subscription_waitingList'] = &$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_waitingList'];
5153
$GLOBALS['TL_DCA']['tl_calendar']['fields']['subscription_waitingListLimit'] = &$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_waitingListLimit'];
54+
$GLOBALS['TL_DCA']['tl_calendar']['fields']['subscription_memberGroupsLimit'] = &$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_memberGroupsLimit'];
55+
$GLOBALS['TL_DCA']['tl_calendar']['fields']['subscription_memberGroups'] = &$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_memberGroups'];
5256

5357
$GLOBALS['TL_DCA']['tl_calendar']['fields']['subscription_reminders'] = [
5458
'label' => &$GLOBALS['TL_LANG']['tl_calendar']['subscription_reminders'],

dca/tl_calendar_events.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
*/
4343
$GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'subscription_override';
4444
$GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'subscription_waitingList';
45-
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['subscription_override'] = 'subscription_types,subscription_maximum,subscription_subscribeEndTime,subscription_unsubscribeEndTime,subscription_waitingList';
45+
$GLOBALS['TL_DCA']['tl_calendar_events']['palettes']['__selector__'][] = 'subscription_memberGroupsLimit';
46+
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['subscription_override'] = 'subscription_types,subscription_maximum,subscription_subscribeEndTime,subscription_unsubscribeEndTime,subscription_waitingList,subscription_memberGroupsLimit';
4647
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['subscription_waitingList'] = 'subscription_waitingListLimit';
48+
$GLOBALS['TL_DCA']['tl_calendar_events']['subpalettes']['subscription_memberGroupsLimit'] = 'subscription_memberGroups';
4749

4850
/**
4951
* Add fields
@@ -68,6 +70,26 @@
6870
'sql' => "blob NULL",
6971
];
7072

73+
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_memberGroupsLimit'] = [
74+
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['subscription_memberGroupsLimit'],
75+
'exclude' => true,
76+
'filter' => true,
77+
'inputType' => 'checkbox',
78+
'eval' => ['submitOnChange' => true],
79+
'sql' => "char(1) NOT NULL default ''",
80+
];
81+
82+
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_memberGroups'] = [
83+
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['subscription_memberGroups'],
84+
'exclude' => true,
85+
'filter' => true,
86+
'inputType' => 'checkbox',
87+
'flag' => 1,
88+
'foreignKey' => 'tl_member_group.name',
89+
'eval' => ['mandatory' => true, 'multiple' => true, 'tl_class' => 'clr'],
90+
'sql' => "blob NULL",
91+
];
92+
7193
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['subscription_maximum'] = [
7294
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['subscription_maximum'],
7395
'exclude' => true,

dca/tl_calendar_events_subscription.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'disableGrouping' => true,
4747
'fields' => ['dateCreated'],
4848
'headerFields' => ['title', 'startDate', 'startTime', 'endDate', 'endTime', 'published'],
49-
'panelLayout' => 'filter,limit',
49+
'panelLayout' => 'filter;limit',
5050
'child_record_callback' => [
5151
'Codefog\EventsSubscriptions\DataContainer\SubscriptionContainer',
5252
'generateLabel',
@@ -89,9 +89,9 @@
8989
// Palettes
9090
'palettes' => [
9191
'__selector__' => ['type'],
92-
'default' => '{type_legend},type,addedBy',
93-
'guest' => '{type_legend},type,addedBy;{guest_legend},firstname,lastname,email',
94-
'member' => '{type_legend},type,addedBy;{member_legend},member',
92+
'default' => '{type_legend},type,addedBy,disableReminders',
93+
'guest' => '{type_legend},type,addedBy,disableReminders;{guest_legend},firstname,lastname,email',
94+
'member' => '{type_legend},type,addedBy,disableReminders;{member_legend},member',
9595
],
9696

9797
// Fields
@@ -137,6 +137,14 @@
137137
'eval' => ['includeBlankOption' => true, 'tl_class' => 'w50'],
138138
'sql' => "int(10) unsigned NOT NULL default '0'",
139139
],
140+
'disableReminders' => [
141+
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events_subscription']['disableReminders'],
142+
'exclude' => true,
143+
'filter' => true,
144+
'inputType' => 'checkbox',
145+
'eval' => ['tl_class' => 'clr'],
146+
'sql' => "char(1) NOT NULL default ''",
147+
],
140148
'member' => [
141149
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events_subscription']['member'],
142150
'exclude' => true,

docs/03-advanced.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ Additionally you have to create and specify the reminder notification in the Not
6767

6868
## Limit subscriptions per member and/or member group
6969

70+
In the calendar and event settings you can optionally restrict which member groups are allowed to subscribe to the
71+
certain events. Simply select the `Member groups restriction` checkbox and choose the desired groups.
72+
7073
It is also possible to limit the amount of possible subscriptions per member and per member group.
7174
You can enable that in the member group and/or member settings:
7275

languages/en/default.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.subscribeNotAllowed'] = 'It is no longer possible to subscribe to this event.';
2020
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.unsubscribeNotAllowed'] = 'It is no longer possible to unsubscribe from this event.';
2121
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.onWaitingList'] = 'waiting list';
22+
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.enableReminders'] = 'Enable reminders';
2223
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.guestForm.firstname'] = 'First name';
2324
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.guestForm.lastname'] = 'Last name';
2425
$GLOBALS['TL_LANG']['MSC']['events_subscriptions.guestForm.email'] = 'E-mail address';

languages/en/tl_calendar_events.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
'Waiting list limit',
4141
'Please enter the waiting list limit. Enter 0 to allow unlimited subscriptions.',
4242
];
43+
$GLOBALS['TL_LANG']['tl_calendar_events']['subscription_memberGroupsLimit'] = [
44+
'Member groups restriction',
45+
'Restrict the subscription to certain member groups. This works only if you have enabled the Member subscription type!',
46+
];
47+
$GLOBALS['TL_LANG']['tl_calendar_events']['subscription_memberGroups'] = [
48+
'Member groups',
49+
'Please choose one or more member groups that are allowed to subscribe.',
50+
];
4351

4452
/**
4553
* Legends

languages/en/tl_calendar_events_subscription.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
'Added by',
2121
'Here you can choose who subscribed this member.',
2222
];
23+
$GLOBALS['TL_LANG']['tl_calendar_events_subscription']['disableReminders'] = [
24+
'Disable reminders',
25+
'Disable the event reminders for this subscriber.',
26+
];
2327
$GLOBALS['TL_LANG']['tl_calendar_events_subscription']['member'] = [
2428
'Member',
2529
'Please choose the member you want to subscribe to the event.',

src/Codefog/EventsSubscriptions/Automator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private function getEvents(CalendarModel $calendar)
145145
$where = (count($where) ? " AND (".implode(" OR ", $where).")" : "");
146146

147147
return Database::getInstance()->prepare(
148-
"SELECT e.*, es.id AS subscriptionId FROM tl_calendar_events_subscription es JOIN tl_calendar_events e ON e.id=es.pid WHERE e.pid=?".$where
148+
"SELECT e.*, es.id AS subscriptionId FROM tl_calendar_events_subscription es JOIN tl_calendar_events e ON e.id=es.pid WHERE e.pid=? AND es.disableReminders=''".$where
149149
)
150150
->execute($calendar->id)
151151
->fetchAllAssoc();

src/Codefog/EventsSubscriptions/EventConfig.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ public function canSubscribe()
8282
return $this->calendar->subscription_enable ? true : false;
8383
}
8484

85+
/**
86+
* Return true if calendar has reminders
87+
*
88+
* @return bool
89+
*/
90+
public function hasReminders()
91+
{
92+
return $this->calendar->subscription_reminders ? true : false;
93+
}
94+
8595
/**
8696
* Get the allowed subscription types
8797
*
@@ -142,6 +152,26 @@ public function getWaitingListLimit()
142152
return (int)$this->get('subscription_waitingListLimit');
143153
}
144154

155+
/**
156+
* Return true if the event has a member groups limit
157+
*
158+
* @return bool
159+
*/
160+
public function hasMemberGroupsLimit()
161+
{
162+
return $this->get('subscription_memberGroupsLimit') ? true : false;
163+
}
164+
165+
/**
166+
* Get the allowed member groups
167+
*
168+
* @return array
169+
*/
170+
public function getMemberGroups()
171+
{
172+
return deserialize($this->get('subscription_memberGroups'), true);
173+
}
174+
145175
/**
146176
* Calculate the time offset
147177
*

src/Codefog/EventsSubscriptions/FrontendModule/SubscriptionTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected function getSubscriptionTemplateData(EventConfig $config, array $modul
3838
'subscribeEndTime' => $this->getSubscribeEndTime($config),
3939
'unsubscribeEndTime' => $this->getUnsubscribeEndTime($config),
4040
'subscribers' => $this->generateEventSubscribers($config),
41+
'subscriptionMaximum' => $config->getMaximumSubscriptions(),
4142
'subscriptionTypes' => [],
4243
];
4344

0 commit comments

Comments
 (0)