/**
* Saves an event in the backend.
*
* @param Kronolith_Event $event The event to save.
*
* @return string The event id.
* @throws Horde_Mime_Exception
*/
protected function _saveEvent($event, $edit)
{
$this->synchronize();
$action = $edit ? array('action' => 'modify') : array('action' => 'add');
if (!$event->uid) {
$event->uid = $this->_data->generateUID();
$event->id = Horde_Url::uriB64Encode($event->uid);
}
$object = $event->toKolab();
if ($edit) {
$this->_data->modify($object);
} else {
$this->_data->create($object);
}
/* Deal with tags */
if ($edit) {
$this->_updateTags($event);
} else {
$this->_addTags($event);
}
/* Notify about the changed event. */
Kronolith::sendNotification($event, $edit ? 'edit' : 'add');
/* Log the creation/modification of this item in the history log. */
try {
$GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $event->calendar . ':' . $event->uid, $action, true);
} catch (Exception $e) {
Horde::log($e, 'ERR');
}
// refresh IMAP cache
$this->synchronize(true);
if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
//Kolab::triggerFreeBusyUpdate($this->_data->parseFolder($event->calendar));
}
return $event->id;
}