xref: /plugin/davcal/ics.php (revision 4ed26d55151fd9e69648a114800407cdb2127288)
1<?php
2
3/**
4 * DoukWiki DAVCal PlugIn - ICS support server
5 */
6
7if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../');
8if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1);
9require_once(DOKU_INC.'inc/init.php');
10session_write_close(); //close session
11
12$path = explode('/', $_SERVER['REQUEST_URI']);
13$icsFile = end($path);
14
15// Load the helper plugin
16$hlp = null;
17$hlp =& plugin_load('helper', 'davcal');
18
19if(is_null($hlp))
20{
21    die('Error loading helper plugin');
22}
23
24if($hlp->getConfig('disable_ics') === 1)
25{
26    die("ICS synchronisation is disabled");
27}
28
29// Retrieve calendar ID based on private URI
30$calid = $hlp->getCalendarForPrivateURL($icsFile);
31
32if($calid === false)
33    die("No calendar with this name known.");
34
35// Retrieve calendar contents and serve
36$stream = $hlp->getCalendarAsICSFeed($calid);
37header("Content-Type: text/calendar");
38header("Content-Transfer-Encoding: Binary");
39header("Content-disposition: attachment; filename=\"calendar.ics\"");
40echo $stream;