diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-06-03 14:54:53 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-06-03 14:54:53 +0200 |
commit | c2a51d1f48acca035abc46b6607dac27dac757d3 (patch) | |
tree | a7815ad7055fa190398c835e823ff68c993e5b9e /apps/calendar/lib | |
parent | ad6562d14fabb0822e197e2ed70e4a3f8c02e23f (diff) | |
download | nextcloud-server-c2a51d1f48acca035abc46b6607dac27dac757d3.tar.gz nextcloud-server-c2a51d1f48acca035abc46b6607dac27dac757d3.zip |
proper export for calendar app - doesn't work with apple ical yet - even though a ics validator says it's valid
Diffstat (limited to 'apps/calendar/lib')
-rw-r--r-- | apps/calendar/lib/export.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/apps/calendar/lib/export.php b/apps/calendar/lib/export.php new file mode 100644 index 00000000000..552515461b2 --- /dev/null +++ b/apps/calendar/lib/export.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class does export + */ +class OC_Calendar_Export{ + const CALENDAR = 'calendar'; + const EVENT = 'event'; + + /* + * @brief export a calendar or an event + * @param (int) $id - id of calendar / event + * @param (const) $type - use OC_Calendar_Export constants + * @return (string) + */ + public static function export($id, $type){ + if($type == self::EVENT){ + $data = OC_Calendar_App::getEventObject($_GET['eventid'], false); + $return = $data['calendardata']; + }else{ + $return = self::calendar($id); + } + return $return; + } + + /* + * @brief export a calendar and convert all times to UTC + * @param (int) $id - id of the calendar + * @return (string) + */ + private static function calendar($id){ + $events = OC_Calendar_Object::all($id); + $return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar\n"; + foreach($events as $event){ + $object = OC_VObject::parse($event['calendardata']); + $dtstart = $object->VEVENT->DTSTART; + $start_dt = $dtstart->getDateTime(); + $dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT); + $end_dt = $dtend->getDateTime(); + if($dtstart->getDateType() !== Sabre_VObject_Element_DateTime::DATE){ + $start_dt->setTimezone(new DateTimeZone('UTC')); + $end_dt->setTimezone(new DateTimeZone('UTC')); + $object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre_VObject_Property_DateTime::UTC); + $object->VEVENT->setDateTime('DTEND', $end_dt, Sabre_VObject_Property_DateTime::UTC); + } + $return .= $object->VEVENT->serialize(); + } + $return .= "END:VCALENDAR"; + return $return; + } +}
\ No newline at end of file |