Skip to content

Commit

Permalink
v2.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed Aug 14, 2019
1 parent ec1538f commit fb137be
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down
11 changes: 8 additions & 3 deletions src/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ApiController extends BaseController
{
protected $allowAnonymous = ['actionIcs'];
protected $allowAnonymous = ['ics'];

/**
* @return null
Expand All @@ -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();
}
}
21 changes: 14 additions & 7 deletions src/Library/Export/AbstractExportCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Variables/CalendarVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/codepack/templates/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
loadOccurrences: false
})) -%}

{% header "Content-Type: application/octet-stream" %}
{% header "Content-Transfer-Encoding: binary" %}
{{- craft.calendar.export(events) -}}

0 comments on commit fb137be

Please sign in to comment.