deleteEvent() public method

Deletes an event.
public deleteEvent ( mixed $eventId, boolean $silent = false )
$eventId mixed Either the event id to delete, or the event object.
$silent boolean Don't send notifications, used when deleting events in bulk from maintenance tasks.
Ejemplo n.º 1
0
Archivo: Base.php Proyecto: 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;
 }
Ejemplo n.º 2
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);
 }