/** * Selects a calendar as the currently opened calendar. * * @param string $calendar A calendar identifier. */ public function open($calendar) { parent::open($calendar); $this->_client = null; $this->_permission = 0; unset($this->_davSupport); }
/** * Process the iCalendar data. * * @return array A hash of UID => id. * @throws Kronolith_Exception */ protected function _process() { $ids = array(); $components = $this->_iCal->getComponents(); if (count($components) == 0) { throw new Kronolith_Exception(_("No iCalendar data was found.")); } foreach ($components as $component) { if (!$this->_preSave($component)) { continue; } try { // RECURRENCE-ID - must import after base event is // imported/saved so defer these until all other data is // processed. $component->getAttribute('RECURRENCE-ID'); $this->_exceptions[] = $component; } catch (Horde_Icalendar_Exception $e) { $event = $this->_driver->getEvent(); $event->fromiCalendar($component, true); // Delete existing exception events. There is no efficient way // to determine if any existing events have been changed/deleted // so we just remove them all since they will be re-added during // the import process. foreach ($event->boundExceptions() as $exception) { $this->_driver->deleteEvent($exception->id); } // Save and post-process. $event->save(); $this->_postSave($event); $ids[$event->uid] = $event->id; } } // Save exception events. foreach ($this->_exceptions as $exception) { $event = $this->_driver->getEvent(); $event->fromiCalendar($exception); $event->save(); } return $ids; }
/** * 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_Sql $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_Sql) { $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); }
/** * Constructor. * * @param Kronolith_Driver $driver The backend driver that this event is * stored in. * @param mixed $eventObject Backend specific event object * that this will represent. */ public function __construct(Kronolith_Driver $driver, $eventObject = null) { $this->calendar = $driver->calendar; list($this->_backgroundColor, $this->_foregroundColor) = $driver->colors(); if (!is_null($eventObject)) { $this->fromDriver($eventObject); } }
/** * Imports a single vEvent part to storage. * * @param Horde_Icalendar_Vevent $content The vEvent part * @param Kronolith_Driver $driver The kronolith driver * @param boolean $exception Content represents an exception * in a recurrence series. * * @return string The new event's uid */ protected function _addiCalEvent($content, $driver, $exception = false) { $event = $driver->getEvent(); $event->fromiCalendar($content, true); // Check if the entry already exists in the data source, first by UID. if (!$exception) { try { $driver->getByUID($event->uid, array($driver->calendar)); throw new Kronolith_Exception(sprintf(_("%s Already Exists"), $event->uid)); } catch (Horde_Exception $e) { } } $result = $driver->search($event); // Check if the match really is an exact match: foreach ($result as $days) { foreach ($days as $match) { if ($match->start->compareDateTime($event->start) == 0 && $match->end->compareDateTime($event->end) == 0 && $match->title == $event->title && $match->location == $event->location && $match->hasPermission(Horde_Perms::EDIT)) { throw new Kronolith_Exception(sprintf(_("%s Already Exists"), $match->uid)); } } } $event->save(); return $event->uid; }
public function open($calendar) { parent::open($calendar); list($this->api, ) = explode('/', $this->calendar, 2); }
/** * Converts a value from the default charset to the driver's * charset. * * @param mixed $value A value to convert. * * @return mixed The converted value. */ public function convertToDriver($value) { return $this->_driver->convertToDriver($value); }