forked from tanghus/journal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.php
46 lines (36 loc) · 1.14 KB
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Copyright (c) 2012 Thomas Tanghus <[email protected]>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$calid = isset($_GET['calid']) ? $_GET['calid'] : null;
$journal = isset($_GET['id']) ? $_GET['id'] : null;
$nl = "\n";
if($calid !== null) {
$calendar = OC_Calendar_App::getCalendar($cal, true);
if($calendar === false) {
header('HTTP/1.0 404 Not Found');
exit;
}
header('Content-Type: text/Calendar');
header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $calendar['displayname']) . '.ics');
$vjournals = OC_Journal_VJournal::all($calid);
if(count($vjournals) > 0) {
foreach($vjournals as $vjournal) {
echo $vjournal['calendardata'] . $nl;
}
}
} elseif($journal !== null) {
$data = OC_Calendar_App::getEventObject($journal, true);
if(!$data){
header('HTTP/1.0 404 Not Found');
exit;
}
header('Content-Type: text/Calendar');
header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $data['summary']) . '.ics');
echo $data['calendardata'];
}