Ejemplo n.º 1
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;
 }