Kronolith_Driver::search PHP Method

    public function search($query, $json = false)
    {
        /* Our default implementation first gets <em>all</em> events in a
         * specific period, and then filters based on the actual values that
         * are filled in. Drivers can optimize this behavior if they have the
         * ability. */
        $results = array();
        $events = $this->listEvents(!empty($query->start) ? $query->start : null, !empty($query->end) ? $query->end : null);
        foreach ($events as $day_events) {
            foreach ($day_events as $event) {
                if (((!isset($query->start) || $event->end->compareDateTime($query->start) > 0) && (!isset($query->end) || $event->end->compareDateTime($query->end) < 0) || $event->recurs() && $event->end->compareDateTime($query->start) >= 0 && $event->start->compareDateTime($query->end) <= 0) && (empty($query->title) || stristr($event->getTitle(), $query->title)) && (empty($query->location) || stristr($event->location, $query->location)) && (empty($query->description) || stristr($event->description, $query->description)) && (empty($query->creator) || stristr($event->creator, $query->creator)) && (!isset($query->status) || $event->status == $query->status) && (empty($query->baseid) || $event->baseid == $query->baseid)) {
                    Kronolith::addEvents($results, $event, $event->start, $event->end, false, $json, false);
                }
            }
        }
        return $results;
    }

Usage Example

Example #1
0
File: Api.php Project: 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;
 }