Skip to content

feat(calendar): enhance iCalendar export functionality to use sabre#1584

Open
JohnVillalovos wants to merge 1 commit into
developfrom
jlvillal/1545_c1
Open

feat(calendar): enhance iCalendar export functionality to use sabre#1584
JohnVillalovos wants to merge 1 commit into
developfrom
jlvillal/1545_c1

Conversation

@JohnVillalovos

Copy link
Copy Markdown
Collaborator

removes template file for ical

Copilot AI review requested due to automatic review settings July 20, 2026 01:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates LibreBooking’s iCalendar (ICS) export from a Smarty template to programmatic generation using sabre/vobject, and removes the now-unused template. It also adjusts PHPStan configuration to accommodate Sabre’s magic-property access patterns.

Changes:

  • Generate VCALENDAR/VEVENT/VALARM output in CalendarExportDisplay using Sabre\VObject instead of tpl/Export/ical.tpl.
  • Remove the legacy ICS Smarty template file.
  • Configure PHPStan to treat Sabre\VObject\Node as a universal object crate to avoid pervasive property.notFound reports.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
Pages/Export/CalendarExportDisplay.php Replaces template rendering with Sabre-based ICS construction (VEVENTs, alarms, extra lines).
tpl/Export/ical.tpl Deleted legacy template that previously emitted raw ICS text.
phpstan.neon Adds Sabre\VObject\Node to universalObjectCratesClasses for baseline analysis.
phpstan_next.neon Mirrors the same PHPStan suppression for the “next” config.

Comment on lines +35 to +56
$isoFormat = 'Ymd\THis\Z';

foreach ($reservations as $res) {
/** @var iCalendarReservationView $res */
$event = new VEvent($vcal, 'VEVENT');
$vcal->add($event);
// VEvent auto-generates UID and DTSTAMP in getDefaults(); use = to replace them.
$event->UID = $res->ReferenceNumber . '&' . $uid;
$event->DTSTAMP = $res->DateCreated->Format($isoFormat);
$event->add('CLASS', $res->Classification);
$event->add('CREATED', $res->DateCreated->Format($isoFormat));
$event->add('DESCRIPTION', $res->Description);
$event->add('DTSTART', $res->DateStart->Format($isoFormat));
$event->add('DTEND', $res->DateEnd->Format($isoFormat));
$event->add('LAST-MODIFIED', $res->LastModified->Format($isoFormat));
$event->add('LOCATION', $res->Location);
$event->add('ORGANIZER', 'mailto:' . $res->OrganizerEmail, ['CN' => $res->Organizer]);
$event->add('STATUS', $res->IsPending ? 'TENTATIVE' : 'CONFIRMED');
$event->add('SUMMARY', $res->Summary);
$event->add('SEQUENCE', 0);
$event->add('URL', $res->ReservationUrl);
$event->add('X-MICROSOFT-CDO-BUSYSTATUS', 'BUSY');
Comment on lines +65 to +68
if ($line !== '' && str_contains($line, ':')) {
[$prop, $val] = explode(':', $line, 2);
$event->add(trim($prop), $val);
}
Comment on lines +75 to +78
$alarm->add('TRIGGER', '-PT' . $res->StartReminder->MinutesPrior() . 'M', ['RELATED' => 'START']);
$alarm->add('ACTION', 'DISPLAY');
$alarm->add('DESCRIPTION', $res->Description);
}
Comment on lines +83 to +86
$alarm->add('TRIGGER', '-PT' . $res->EndReminder->MinutesPrior() . 'M', ['RELATED' => 'END']);
$alarm->add('ACTION', 'DISPLAY');
$alarm->add('DESCRIPTION', $res->Summary);
}
* @return string
*/
public function Render($reservations)
public function Render(array $reservations, ?string $calendarName = null): string
@JohnVillalovos
JohnVillalovos requested a review from lucs7 July 20, 2026 01:37
@JohnVillalovos

Copy link
Copy Markdown
Collaborator Author

@lucs7 Can you look at this PR? It is the first commit from your PR. Feel free to make changes on your PR and I can update this one. Or if you want create a new PR with just this one commit.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants