aboutsummaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax/events.php
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-03-19 08:33:36 +0100
committerGeorg Ehrke <dev@georgswebsite.de>2012-03-19 08:33:36 +0100
commit33b06c448443bb0085ff986c341594d80903f43b (patch)
treee80977f084f5f149471995976edb4a01eee886a9 /apps/calendar/ajax/events.php
parent097ce76fc4383c68856ee70db0c87f0e9f5fefb4 (diff)
parentde09883d860d6507a2d287d0b8bae394963c4b94 (diff)
downloadnextcloud-server-33b06c448443bb0085ff986c341594d80903f43b.tar.gz
nextcloud-server-33b06c448443bb0085ff986c341594d80903f43b.zip
Merge branch 'master' into sabredav_1.6
Diffstat (limited to 'apps/calendar/ajax/events.php')
-rwxr-xr-xapps/calendar/ajax/events.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
index 6ea556a7abf..dff02e15875 100755
--- a/apps/calendar/ajax/events.php
+++ b/apps/calendar/ajax/events.php
@@ -27,25 +27,40 @@ function create_return_event($event, $vevent){
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
-$start = DateTime::createFromFormat('U', $_GET['start']);
-$end = DateTime::createFromFormat('U', $_GET['end']);
+if(version_compare(PHP_VERSION, '5.3.0', '>=')){
+ $start = DateTime::createFromFormat('U', $_GET['start']);
+ $end = DateTime::createFromFormat('U', $_GET['end']);
+}else{
+ $start = new DateTime('@' . $_GET['start']);
+ $end = new DateTime('@' . $_GET['end']);
+}
-$calendar = OC_Calendar_App::getCalendar($_GET['calendar_id']);
-OC_Response::enableCaching(0);
-OC_Response::setETagHeader($calendar['ctag']);
+$calendar_id = $_GET['calendar_id'];
+if (is_numeric($calendar_id)) {
+ $calendar = OC_Calendar_App::getCalendar($calendar_id);
+ OC_Response::enableCaching(0);
+ OC_Response::setETagHeader($calendar['ctag']);
+ $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end);
+} else {
+ $events = array();
+ OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events));
+}
-$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$return = array();
foreach($events as $event){
- $object = OC_VObject::parse($event['calendardata']);
- $vevent = $object->VEVENT;
+ if (isset($event['calendardata'])) {
+ $object = OC_VObject::parse($event['calendardata']);
+ $vevent = $object->VEVENT;
+ } else {
+ $vevent = $event['vevent'];
+ }
$return_event = create_return_event($event, $vevent);
$dtstart = $vevent->DTSTART;
- $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$start_dt = $dtstart->getDateTime();
+ $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$end_dt = $dtend->getDateTime();
if ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE){
$return_event['allDay'] = true;