Skip to content

Commit 03eb13d

Browse files
committed
add calendar public flag option
1 parent 2e7ffa4 commit 03eb13d

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ CALDAV_ENABLED=true
6969
CARDDAV_ENABLED=true
7070
WEBDAV_ENABLED=false
7171

72+
# Can calendar be public available ?
73+
PUBLIC_CALENDAR_ENABLED=false
74+
7275
# What mail is used as the sender for invites ?
7376
INVITE_FROM_ADDRESS=no-reply@example.org
7477

config/services.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ parameters:
77
default_database_driver: "mysql"
88
default_admin_auth_bypass: "false"
99
timezone: '%env(APP_TIMEZONE)%'
10+
public_calendar_enabled: '%env(bool:PUBLIC_CALENDAR_ENABLED)%'
1011

1112
services:
1213
# default configuration for services in *this* file

src/Controller/Admin/CalendarController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function calendarEdit(ManagerRegistry $doctrine, Request $request, string
8383
$form = $this->createForm(CalendarInstanceType::class, $calendarInstance, [
8484
'new' => !$id,
8585
'shared' => $calendarInstance->isShared(),
86+
'public_calendar_enabled' => $this->getParameter('public_calendar_enabled')
8687
]);
8788

8889
$components = explode(',', $calendarInstance->getCalendar()->getComponents());

src/Form/CalendarInstanceType.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,21 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
2727
'help' => 'form.uri.help.caldav',
2828
'required' => true,
2929
])
30-
->add('public', ChoiceType::class, [
31-
'label' => 'form.public',
32-
'mapped' => false,
33-
'disabled' => $options['shared'],
34-
'help' => 'form.public.help.caldav',
35-
'required' => true,
36-
'choices' => ['yes' => true, 'no' => false],
37-
])
30+
->add(
31+
'public',
32+
$options['public_calendar_enabled'] ? ChoiceType::class : HiddenType::class,
33+
$options['public_calendar_enabled'] ? [
34+
'label' => 'form.public',
35+
'mapped' => false,
36+
'disabled' => $options['shared'],
37+
'help' => 'form.public.help.caldav',
38+
'required' => true,
39+
'choices' => ['yes' => true, 'no' => false],
40+
] : [
41+
'required' => true,
42+
'mapped' => false,
43+
]
44+
)
3845
->add('displayName', TextType::class, [
3946
'label' => 'form.displayName',
4047
'help' => 'form.name.help.caldav',

0 commit comments

Comments
 (0)