getEvent() public method

Stub to be overridden in the child class.
public getEvent ( $eventId = null )
示例#1
0
文件: Resource.php 项目: horde/horde
 /**
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  */
 public function getEvent($eventId = null)
 {
     if (!strlen($eventId)) {
         $event = new $this->_eventClass($this);
         $event->calendar = $this->calendar;
         return $event;
     }
     $driver_event = $this->_driver->getEvent($eventId);
     $event = $this->_buildResourceEvent($driver_event);
     return $event;
 }
示例#2
0
文件: Base.php 项目: horde/horde
 /**
  * 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;
 }
示例#3
0
文件: Api.php 项目: horde/horde
 /**
  * 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;
 }