1<?php
2/**
3 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Esther Brunner <wikidesign@gmail.com>
5 */
6if (!defined('CRLF')) define('CRLF', "\r\n");
7if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__)).'/../../../');
8
9require_once(DOKU_INC.'inc/init.php');
10require_once(DOKU_INC.'inc/common.php');
11require_once(DOKU_INC.'inc/infoutils.php');
12require_once(DOKU_INC.'inc/pageutils.php');
13require_once(DOKU_INC.'inc/parserutils.php');
14
15$id = $_REQUEST['id'];
16
17$data = unserialize(io_readFile(metaFN($id, '.task'), false));
18if (!$data['vtodo']) msg('No VTODO data for this task.', -1);
19
20$title = p_get_metadata($id, 'title');
21if($title) {
22    $filename = $title . '.ics';
23} else {
24    $filename = str_replace(':', '/', cleanID($id)) . '.ics';
25}
26
27$output = 'BEGIN:VCALENDAR'.CRLF.
28  'PRODID:-//Wikidesign//NONSGML Task Plugin for DokuWiki//EN'.CRLF.
29  'VERSION:2.0'.CRLF.
30  $data['vtodo'].
31  'END:VCALENDAR'.CRLF;
32
33header("Content-Disposition: attachment; filename='$filename'");
34header('Content-Length: '.strlen($output));
35header('Connection: close');
36header("Content-Type: text/Calendar; name='$filename'");
37
38echo $output;
39
40// vim:ts=4:sw=4:et:enc=utf-8:
41