2011-10-17 21:58:56 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once ("../../../lib/base.php");
|
|
|
|
if(!OC_USER::isLoggedIn()) {
|
|
|
|
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
|
|
|
|
}
|
|
|
|
OC_JSON::checkAppEnabled('calendar');
|
|
|
|
|
|
|
|
$start = DateTime::createFromFormat('U', $_GET['start']);
|
|
|
|
$end = DateTime::createFromFormat('U', $_GET['end']);
|
|
|
|
|
|
|
|
$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
|
|
|
|
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
|
|
|
|
$return = array();
|
|
|
|
foreach($events as $event)
|
|
|
|
{
|
2011-10-22 00:59:26 +04:00
|
|
|
$return_event = array();
|
2011-10-17 21:58:56 +04:00
|
|
|
$object = Sabre_VObject_Reader::read($event['calendardata']);
|
|
|
|
$vevent = $object->VEVENT;
|
|
|
|
$dtstart = $vevent->DTSTART;
|
|
|
|
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
|
|
|
$start_dt = $dtstart->getDateTime();
|
|
|
|
$end_dt = $dtend->getDateTime();
|
|
|
|
if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE)
|
|
|
|
{
|
|
|
|
$return_event['allDay'] = true;
|
2011-10-22 00:47:31 +04:00
|
|
|
$return_event['start'] = $start_dt->format('Y-m-d');
|
2011-10-17 21:58:56 +04:00
|
|
|
$end_dt->modify('-1 sec');
|
2011-10-22 00:47:31 +04:00
|
|
|
$return_event['end'] = $end_dt->format('Y-m-d');
|
|
|
|
}else{
|
|
|
|
$start_dt->setTimezone(new DateTimeZone($user_timezone));
|
|
|
|
$end_dt->setTimezone(new DateTimeZone($user_timezone));
|
|
|
|
$return_event['start'] = $start_dt->format('Y-m-d H:i:s');
|
2011-10-18 23:15:11 +04:00
|
|
|
$return_event['end'] = $end_dt->format('Y-m-d H:i:s');
|
2011-10-22 00:47:31 +04:00
|
|
|
$return_event['allDay'] = false;
|
2011-10-17 21:58:56 +04:00
|
|
|
}
|
2011-10-22 00:47:31 +04:00
|
|
|
$return_event['id'] = $event['id'];
|
|
|
|
$return_event['title'] = $event['summary'];
|
|
|
|
$return_event['description'] = isset($vevent->DESCRIPTION)?$vevent->DESCRIPTION->value:'';
|
2011-10-17 21:58:56 +04:00
|
|
|
$return[] = $return_event;
|
|
|
|
}
|
|
|
|
OC_JSON::encodedPrint($return);
|