From fb137becea73c4cdb8bfa917d39694b82ba7c15a Mon Sep 17 00:00:00 2001 From: Kelsey Martens Date: Wed, 14 Aug 2019 15:03:57 -0500 Subject: [PATCH] v2.0.24 --- CHANGELOG.md | 5 +++++ composer.json | 2 +- src/Controllers/ApiController.php | 11 +++++++--- src/Library/Export/AbstractExportCalendar.php | 21 ++++++++++++------- src/Variables/CalendarVariable.php | 4 +++- src/codepack/templates/export.html | 2 ++ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19baf12a..1b57f7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Solspace Calendar Changelog +## 2.0.24 - 2019-08-14 +### Fixed +- Fixed a bug where ICS export was not exporting correctly for Safari. +- Fixed a bug where ICS subscription URL's were no longer working at all. + ## 2.0.23 - 2019-08-13 ### Fixed - Fixed a bug where ICS export was not working correctly when `devMode` was disabled. diff --git a/composer.json b/composer.json index 90b49659..69e45393 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "solspace/craft3-calendar", "description": "The most powerful event management plugin for Craft.", - "version": "2.0.23", + "version": "2.0.24", "type": "craft-plugin", "authors": [ { diff --git a/src/Controllers/ApiController.php b/src/Controllers/ApiController.php index 093eb9ea..345a4332 100644 --- a/src/Controllers/ApiController.php +++ b/src/Controllers/ApiController.php @@ -9,7 +9,7 @@ class ApiController extends BaseController { - protected $allowAnonymous = ['actionIcs']; + protected $allowAnonymous = ['ics']; /** * @return null @@ -29,11 +29,16 @@ public function actionIcs() ->setLoadOccurrences(false) ->setCalendarId($calendar->id); - $exporter = new ExportCalendarToIcs($eventQuery); + $exporter = new ExportCalendarToIcs($eventQuery); + $exportString = $exporter->output(); header('Content-type: text/calendar; charset=utf-8'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . strlen($exportString)); - echo $exporter->output(); + echo $exportString; exit(); } } diff --git a/src/Library/Export/AbstractExportCalendar.php b/src/Library/Export/AbstractExportCalendar.php index 2760c1c2..9ac6e90e 100644 --- a/src/Library/Export/AbstractExportCalendar.php +++ b/src/Library/Export/AbstractExportCalendar.php @@ -26,25 +26,32 @@ final public function __construct(EventQuery $events, array $options = []) * Collects the exportable string and outputs it * Sets headers to file download and content-type to text/calendar * + * @param bool $asFileUpload + * @param bool $shouldExit + * * @return string */ - final public function export() + final public function export(bool $asFileUpload = true, bool $shouldExit = true) { $exportString = $this->prepareStringForExport(); header('Content-Type: text/calendar; charset=utf-8'); - header('Content-Disposition: attachment; filename="' . time() . '.ics"'); - - header('Content-Description: File Transfer'); - header('Content-Type: text/calendar; charset=utf-8'); - header('Content-Disposition: attachment; filename="' . time() . '.ics"'); - header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . strlen($exportString)); + if ($asFileUpload) { + header('Content-Description: File Transfer'); + header('Content-Disposition: attachment; filename="' . time() . '.ics"'); + header('Content-Transfer-Encoding: binary'); + } + echo $exportString; + + if ($shouldExit) { + exit(); + } } /** diff --git a/src/Variables/CalendarVariable.php b/src/Variables/CalendarVariable.php index 319780e5..810a877b 100644 --- a/src/Variables/CalendarVariable.php +++ b/src/Variables/CalendarVariable.php @@ -105,11 +105,13 @@ public function event($id, array $options = []) /** * @param EventQuery $events * @param array $options + * + * @return string */ public function export(EventQuery $events, array $options = []) { $exporter = new ExportCalendarToIcs($events, $options); - $exporter->export(); + $exporter->export(true, false); } /** diff --git a/src/codepack/templates/export.html b/src/codepack/templates/export.html index 7ba4176f..a23fbc66 100755 --- a/src/codepack/templates/export.html +++ b/src/codepack/templates/export.html @@ -19,4 +19,6 @@ loadOccurrences: false })) -%} +{% header "Content-Type: application/octet-stream" %} +{% header "Content-Transfer-Encoding: binary" %} {{- craft.calendar.export(events) -}}