getByUID() public method

Stub to be overridden in the child class.
public getByUID ( $uid, $calendars = null, $getAll = false )
Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
Archivo: Api.php Proyecto: 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;
 }