/**
* Delete an event.
*
* Since this is the Kronolith_Resource's version of the event, if we
* delete it, we must also make sure to remove it from the event that
* it is attached to. Not sure if there is a better way to do this...
*
* @param string|Kronolith_Event_Resource $eventId The ID of the event
* to delete.
* @param boolean $silent Don't send notifications, used when deleting
* events in bulk from maintenance tasks.
* @param boolean $keep_bound If true, does not remove the resource from
* the bound event. @since 4.2.2
*
* @throws Kronolith_Exception
* @throws Horde_Exception_NotFound
*/
public function deleteEvent($eventId, $silent = false, $keep_bound = false)
{
if ($eventId instanceof Kronolith_Event_Resource) {
$delete_event = $eventId;
$eventId = $delete_event->id;
} else {
$delete_event = $this->getEvent($eventId);
}
if ($keep_bound) {
return;
}
$uid = $delete_event->uid;
$events = $this->_driver->getByUID($uid, null, true);
foreach ($events as $e) {
$resources = $e->getResources();
if (count($resources)) {
$r = $this->getResource($this->getResourceIdByCalendar($delete_event->calendar));
$e->removeResource($r);
$e->save();
}
}
$this->_driver->open($this->calendar);
$this->_driver->deleteEvent($delete_event, $silent);
}