getDriver() public method

Returns a reference to a driver that's valid for this event.
public getDriver ( ) : Kronolith_Driver
return Kronolith_Driver A driver that this event can use to save itself, etc.
Ejemplo n.º 1
0
 /**
  * Creates a new event that represents an exception to a recurring event.
  *
  * @param Kronolith_Event $event  The original recurring event.
  * @param Kronolith_Event $copy   If present, contains a copy of $event, but
  *                                with changes from edited event form.
  * @param stdClass $attributes    The attributes passed from the client.
  *                                Expected to contain rstart and rend or
  *                                rday that represents the original
  *                                starting/ending date of the instance.
  *
  * @return Kronolith_Event  The event representing the exception
  */
 protected function _copyEvent(Kronolith_Event $event, Kronolith_Event $copy = null, $attributes = null)
 {
     if (empty($copy)) {
         $copy = clone $event;
     }
     if ($attributes->rstart) {
         $rstart = new Horde_Date($attributes->rstart);
         $rstart->setTimezone($event->start->timezone);
         $rend = new Horde_Date($attributes->rend);
         $rend->setTimezone($event->end->timezone);
     } else {
         $rstart = new Horde_Date($attributes->rday);
         $rstart->setTimezone($event->start->timezone);
         $rstart->hour = $event->start->hour;
         $rstart->min = $event->start->min;
         $rend = $rstart->add($event->getDuration);
         $rend->setTimezone($event->end->timezone);
         $rend->hour = $event->end->hour;
         $rend->min = $event->end->min;
     }
     $uid = $event->uid;
     $otime = $event->start->strftime('%T');
     // Create new event for the exception
     $nevent = $event->getDriver()->getEvent();
     $nevent->baseid = $uid;
     $nevent->exceptionoriginaldate = new Horde_Date($rstart->strftime('%Y-%m-%d') . 'T' . $otime);
     $nevent->exceptionoriginaldate->setTimezone($event->start->timezone);
     $nevent->creator = $event->creator;
     $nevent->title = $copy->title;
     $nevent->description = $copy->description;
     $nevent->location = $copy->location;
     $nevent->private = $copy->private;
     $nevent->url = $copy->url;
     $nevent->status = $copy->status;
     $nevent->attendees = $copy->attendees;
     $nevent->setResources($copy->getResources());
     $nevent->start = $rstart;
     $nevent->end = $rend;
     $nevent->initialized = true;
     return $nevent;
 }
Ejemplo n.º 2
0
 /**
  * Adds an event to set of search results.
  *
  * @param array $events           The list of events to update with the new
  *                                event.
  * @param Kronolith_Event $event  An event from a search result.
  * @param stdClass $query         A search query.
  * @param boolean $json           Store the results of the events' toJson()
  *                                method?
  */
 public static function addSearchEvents(&$events, $event, $query, $json)
 {
     static $now;
     if (!isset($now)) {
         $now = new Horde_Date($_SERVER['REQUEST_TIME']);
     }
     $showRecurrence = true;
     if ($event->recurs()) {
         if (empty($query->start) && empty($query->end)) {
             $eventStart = $event->start;
             $eventEnd = $event->end;
         } else {
             if (empty($query->end)) {
                 $convert = $event->timezone && $event->getDriver()->supportsTimezones();
                 if ($convert) {
                     $timezone = date_default_timezone_get();
                     $event->recurrence->start->setTimezone($event->timezone);
                     if ($event->recurrence->hasRecurEnd()) {
                         $event->recurrence->recurEnd->setTimezone($event->timezone);
                     }
                 }
                 $eventEnd = $event->recurrence->nextRecurrence($now);
                 if (!$eventEnd) {
                     return;
                 }
                 if ($convert) {
                     $eventEnd->setTimezone($timezone);
                 }
             } else {
                 $eventEnd = $query->end;
             }
             if (empty($query->start)) {
                 $eventStart = $event->start;
                 $showRecurrence = false;
             } else {
                 $eventStart = $query->start;
             }
         }
     } else {
         $eventStart = $event->start;
         $eventEnd = $event->end;
     }
     self::addEvents($events, $event, $eventStart, $eventEnd, $showRecurrence, $json, false);
 }