From: Michael J. Rubinsky Date: Fri, 18 Dec 2009 18:37:31 +0000 (-0500) Subject: Don't use an intermediate iCalendar object to do this, just copy the X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7e5b43bf0a5d4a6397b253ee04b27cf27275192b;p=horde.git Don't use an intermediate iCalendar object to do this, just copy the necessary event object properties manually. --- diff --git a/kronolith/lib/Resource/Single.php b/kronolith/lib/Resource/Single.php index 8c142c5da..4caa6ca2b 100644 --- a/kronolith/lib/Resource/Single.php +++ b/kronolith/lib/Resource/Single.php @@ -88,14 +88,19 @@ class Kronolith_Resource_Single extends Kronolith_Resource_Base $existing = $driver->getByUID($uid, array($this->get('calendar'))); if (!($existing instanceof PEAR_Error)) { /* Already attached, just update */ - $existing->fromiCalendar($event->toiCalendar(new Horde_iCalendar('2.0'))); - $existing->status = $event->status; - $existing->save(); + $this->_copyEvent($event, $existing); + $result = $existing->save(); + if (is_a($result, 'PEAR_Error')) { + throw new Kronolith_Exception($result->getMessage()); + } } else { /* Create a new event */ $e = $driver->getEvent(); - $e->fromiCalendar($event->toiCalendar(new Horde_iCalendar('2.0'))); - $e->save(); + $this->_copyEvent($event, $e); + $result = $e->save(); + if (is_a($result, 'PEAR_Error')) { + throw new Kronolith_Exception($result->getMessage()); + } } } @@ -144,4 +149,33 @@ class Kronolith_Resource_Single extends Kronolith_Resource_Base return $this->get('response_type'); } + /** + * Utility function to copy select event properties from $from to $to in + * order to add an event to the resource calendar. + * + * @param Kronolith_Event $from + * @param Kronolith_Event $to + * + * @return void + */ + private function _copyEvent($from, &$to) + { + $to->uid = $from->uid; + $to->title = $from->title; + $to->location = $from->location; + $to->status = $from->status; + $to->description = $from->description; + $to->url = $from->url; + $to->tags = $from->tags; + $to->geoLocation = $from->geoLocation; + $to->first = $from ->first; + $to->last = $from->last; + $to->start = $from->start; + $to->end = $from->end; + $to->durMin = $from->durMin; + $to->allday = $from->allday; + $to->recurrence = $from->recurrence; + $to->initialized = true; + } + } \ No newline at end of file