VEVENT is not compulsory for a calendar

This commit is contained in:
Cyril 2019-12-03 12:28:35 +01:00
parent dd6b023954
commit a2ae8a7d2c
4 changed files with 21 additions and 3 deletions

View File

@ -246,6 +246,7 @@ class AdminController extends AbstractController
$components = explode(',', $calendarInstance->getCalendar()->getComponents());
$form->get('events')->setData(in_array(Calendar::COMPONENT_EVENTS, $components));
$form->get('todos')->setData(in_array(Calendar::COMPONENT_TODOS, $components));
$form->get('notes')->setData(in_array(Calendar::COMPONENT_NOTES, $components));
$form->get('principalUri')->setData(Principal::PREFIX.$username);
@ -253,7 +254,10 @@ class AdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$components = [Calendar::COMPONENT_EVENT]; // We always need VEVENT
$components = [];
if ($form->get('events')->getData()) {
$components[] = Calendar::COMPONENT_EVENTS;
}
if ($form->get('todos')->getData()) {
$components[] = Calendar::COMPONENT_TODOS;
}

View File

@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Calendar
{
const COMPONENT_EVENT = 'VEVENT';
const COMPONENT_EVENTS = 'VEVENT';
const COMPONENT_TODOS = 'VTODO';
const COMPONENT_NOTES = 'VJOURNAL';
@ -46,7 +46,7 @@ class Calendar
public function __construct()
{
$this->synctoken = 1;
$this->components = 'VEVENT,VTODO';
$this->components = static::COMPONENT_EVENTS;
$this->objects = new ArrayCollection();
$this->changes = new ArrayCollection();
}

View File

@ -40,6 +40,12 @@ class CalendarInstanceType extends AbstractType
'help' => 'form.color.help',
'attr' => ['placeholder' => '#RRGGBBAA'],
])
->add('events', CheckboxType::class, [
'label' => 'form.events',
'mapped' => false,
'help' => 'form.events.help',
'required' => false,
])
->add('todos', CheckboxType::class, [
'label' => 'form.todos',
'mapped' => false,

View File

@ -281,6 +281,10 @@
<source>form.username.help</source>
<target>May be an email, but not forcibly.</target>
</trans-unit>
<trans-unit id="2bl0WGs" resname="form.events">
<source>form.events</source>
<target>Events</target>
</trans-unit>
<trans-unit id="h0fN2H5" resname="form.notes">
<source>form.notes</source>
<target>Notes</target>
@ -321,6 +325,10 @@
<source>form.color.help</source>
<target>This is the color that will be displayed in your CalDAV client. It must be supplied in the format '#RRGGBBAA' (alpha channel is optional) with hexadecimal values. This value is optional.</target>
</trans-unit>
<trans-unit id="nYaXSuu" resname="form.events.help">
<source>form.events.help</source>
<target>If checked, events will be enabled on this calendar. It will show up in calendar clients.</target>
</trans-unit>
<trans-unit id="KBkKkDQ" resname="form.todos.help">
<source>form.todos.help</source>
<target>If checked, todos will be enabled on this calendar. It will show up in reminders clients (such as macOS Reminders app)</target>