diff options
author | Bart Visscher <bartv@thisnet.nl> | 2011-09-20 14:41:17 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2011-12-07 20:40:58 +0100 |
commit | c67ac46b6c3b333c7f16cbdc8df7b9a6b4f3fb1b (patch) | |
tree | 14d2a1f3061f5e8236bdd106c9b0dea9bbbe9c4d /apps/calendar/ajax | |
parent | b9e6f5e42d54fc91205f03f4b19bbf313278f476 (diff) | |
download | nextcloud-server-c67ac46b6c3b333c7f16cbdc8df7b9a6b4f3fb1b.tar.gz nextcloud-server-c67ac46b6c3b333c7f16cbdc8df7b9a6b4f3fb1b.zip |
Use a proxy class to interface with Sabre_VObject classes
Diffstat (limited to 'apps/calendar/ajax')
-rw-r--r-- | apps/calendar/ajax/editevent.php | 2 | ||||
-rw-r--r-- | apps/calendar/ajax/editeventform.php | 16 | ||||
-rw-r--r-- | apps/calendar/ajax/events.php | 2 | ||||
-rw-r--r-- | apps/calendar/ajax/moveevent.php | 12 |
4 files changed, 11 insertions, 21 deletions
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php index 46feb068499..e3c84520481 100644 --- a/apps/calendar/ajax/editevent.php +++ b/apps/calendar/ajax/editevent.php @@ -34,7 +34,7 @@ if($errarr){ OC_JSON::error(); exit; } - $vcalendar = OC_Calendar_Object::parse($data['calendardata']); + $vcalendar = OC_VObject::parse($data['calendardata']); $last_modified = $vcalendar->VEVENT->__get('LAST-MODIFIED'); if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){ diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php index 63c72934079..c91f136e898 100644 --- a/apps/calendar/ajax/editeventform.php +++ b/apps/calendar/ajax/editeventform.php @@ -26,7 +26,7 @@ if($calendar['userid'] != OC_User::getUser()){ echo $l10n->t('Wrong calendar'); exit; } -$object = OC_Calendar_Object::parse($data['calendardata']); +$object = OC_VObject::parse($data['calendardata']); $vevent = $object->VEVENT; $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); @@ -49,20 +49,16 @@ switch($dtstart->getDateType()) { break; } -$summary = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : ''; -$location = isset($vevent->LOCATION) ? $vevent->LOCATION->value : ''; -$categories = array(); -if (isset($vevent->CATEGORIES)){ - $categories = explode(',', $vevent->CATEGORIES->value); - $categories = array_map('trim', $categories); -} +$summary = $vevent->getAsString('SUMMARY'); +$location = $vevent->getAsString('LOCATION'); +$categories = $vevent->getAsArray('CATEGORIES'); +$repeat = $vevent->getAsString('CATEGORY'); +$description = $vevent->getAsString('DESCRIPTION'); foreach($categories as $category){ if (!in_array($category, $category_options)){ array_unshift($category_options, $category); } } -$repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : ''; -$description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : ''; $last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified){ $lastmodified = $last_modified->getDateTime()->format('U'); diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 1ef6bd30594..1430432b8a3 100644 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -33,7 +33,7 @@ $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_Calendar_Object::parse($event['calendardata']); + $object = OC_VObject::parse($event['calendardata']); $vevent = $object->VEVENT; $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php index 6b315a39213..51fafdfeb97 100644 --- a/apps/calendar/ajax/moveevent.php +++ b/apps/calendar/ajax/moveevent.php @@ -22,7 +22,7 @@ $delta = new DateInterval('P0D'); $delta->d = $_POST['dayDelta']; $delta->i = $_POST['minuteDelta']; -$vcalendar = OC_Calendar_Object::parse($data['calendardata']); +$vcalendar = OC_VObject::parse($data['calendardata']); $vevent = $vcalendar->VEVENT; $last_modified = $vevent->__get('LAST-MODIFIED'); @@ -46,14 +46,8 @@ $dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type); $dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); unset($vevent->DURATION); -$now = new DateTime(); -$last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED'); -$last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC); -$vevent->__set('LAST-MODIFIED', $last_modified); - -$dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP'); -$dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC); -$vevent->DTSTAMP = $dtstamp; +$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); +$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); OC_JSON::success(array('lastmodified'=>(int)$now->format('U'))); |