sendITipNotifications() public static method

Can be used to send event invitations, event updates as well as event cancellations.
public static sendITipNotifications ( Kronolith_Event $event, Horde_Notification_Handler $notification, integer $action, Horde_Date $instance = null, string $range = null, Kronolith_Attendee_List $cancellations = null )
$event Kronolith_Event The event in question.
$notification Horde_Notification_Handler A notification object used to show result status.
$action integer The type of notification to send. One of the Kronolith::ITIP_* values.
$instance Horde_Date If cancelling a single instance of a recurring event, the date of this instance.
$range string The range parameter if this is a recurring event. Possible values are self::RANGE_THISANDFUTURE
$cancellations Kronolith_Attendee_List If $action is 'CANCEL', but it is due to removing attendees and not canceling the entire event, these are the uninvited attendees and are the ONLY people that will receive the CANCEL iTIP. @since 4.2.10
Esempio n. 1
0
/**
 * Copyright 1999-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Chuck Hagenbuch <*****@*****.**>
 * @package Kronolith
 */
function _save(&$event)
{
    try {
        $event->save();
        if (Horde_Util::getFormData('sendupdates', false)) {
            Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_REQUEST);
        }
    } catch (Exception $e) {
        $GLOBALS['notification']->push(sprintf(_("There was an error editing the event: %s"), $e->getMessage()), 'horde.error');
    }
    Kronolith::notifyOfResourceRejection($event);
}
Esempio n. 2
0
 /**
  * Deletes an event, or an instance of an event series from the backend.
  *
  * Uses the following request variables:
  *<pre>
  *   - cal:          The calendar id.
  *   - id:           The event id.
  *   - r:            If this is an event series, what type of deletion to
  *                   perform [future | current | all].
  *   - rstart:       The start time of the event instance being removed, if
  *                   this is a series instance.
  *   - cstart:       The start date of the client event cache.
  *   - cend:         The end date of the client event cache.
  *   - sendupdates:  Send cancellation notice to attendees?
  * </pre>
  */
 public function deleteEvent()
 {
     $result = new stdClass();
     $instance = null;
     if (!($kronolith_driver = $this->_getDriver($this->vars->cal)) || !isset($this->vars->id)) {
         return $result;
     }
     try {
         $event = $kronolith_driver->getEvent($this->vars->id);
         if (!$event->hasPermission(Horde_Perms::DELETE)) {
             $GLOBALS['notification']->push(_("You do not have permission to delete this event."), 'horde.warning');
             return $result;
         }
         $range = null;
         if ($event->recurs() && $this->vars->r != 'all') {
             switch ($this->vars->r) {
                 case 'future':
                     // Deleting all future instances.
                     // @TODO: Check if we need to find future exceptions
                     //        that are after $recurEnd and remove those as well.
                     $instance = new Horde_Date($this->vars->rstart, $event->timezone);
                     $recurEnd = clone $instance;
                     $recurEnd->hour = 0;
                     $recurEnd->min = 0;
                     $recurEnd->sec = 0;
                     $recurEnd->mday--;
                     if ($event->end->compareDate($recurEnd) > 0) {
                         $kronolith_driver->deleteEvent($event->id);
                         $result = $this->_signedResponse($this->vars->cal);
                         $result->events = array();
                     } else {
                         $event->recurrence->setRecurEnd($recurEnd);
                         $result = $this->_saveEvent($event, $event, $this->vars);
                     }
                     $range = Kronolith::RANGE_THISANDFUTURE;
                     break;
                 case 'current':
                     // Deleting only the current instance.
                     $instance = new Horde_Date($this->vars->rstart, $event->timezone);
                     $event->recurrence->addException($instance->year, $instance->month, $instance->mday);
                     $result = $this->_saveEvent($event, $event, $this->vars);
             }
         } else {
             // Deleting an entire series, or this is a single event only.
             $kronolith_driver->deleteEvent($event->id);
             $result = $this->_signedResponse($this->vars->cal);
             $result->events = array();
             $result->uid = $event->uid;
         }
         if ($this->vars->sendupdates) {
             Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_CANCEL, $instance, $range);
         }
         $result->deleted = true;
     } catch (Horde_Exception_NotFound $e) {
         $GLOBALS['notification']->push(_("The requested event was not found."), 'horde.error');
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
     }
     return $result;
 }
Esempio n. 3
0
            } else {
                $event->recurrence->setRecurEnd($recurEnd);
                $event->save();
            }
            $notification_type = Kronolith::ITIP_REQUEST;
        } elseif (Horde_Util::getFormData('current')) {
            $event->recurrence->addException(Horde_Util::getFormData('year'), Horde_Util::getFormData('month'), Horde_Util::getFormData('mday'));
            $event->save();
            $instance = new Horde_Date(array('year' => Horde_Util::getFormData('year'), 'month' => Horde_Util::getFormData('month'), 'mday' => Horde_Util::getFormData('mday')));
        }
        if (!$event->recurs() || Horde_Util::getFormData('all') || !$event->recurrence->hasActiveRecurrence()) {
            try {
                $kronolith_driver->deleteEvent($event->id);
            } catch (Exception $e) {
                $notification->push($e, 'horde.error');
            }
        }
        if (Horde_Util::getFormData('sendupdates', false)) {
            Kronolith::sendITipNotifications($event, $notification, $notification_type, $instance);
        }
    }
}
$url = Horde_Util::getFormData('url');
if (!empty($url)) {
    $url = new Horde_Url($url, true);
} else {
    $date = new Horde_Date(Horde_Util::getFormData('date'));
    $url = Horde::url($prefs->getValue('defaultview') . '.php', true)->add('date', Horde_Util::getFormData('date', date('Ymd')));
}
// Make sure URL is unique.
$url->unique()->redirect();
Esempio n. 4
0
            $notification->push(_("You do not have permission to delegate events to this user."), 'horde.warning');
            break;
        }
        $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
        if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
            Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
            break;
        }
        $event = Kronolith::getDriver($targetType, $calendar_id)->getEvent();
        $event->readForm();
        try {
            $event->save();
            Kronolith::notifyOfResourceRejection($event);
            if (Horde_Util::getFormData('sendupdates', false)) {
                try {
                    Kronolith::sendITipNotifications($event, $notification, Kronolith::ITIP_REQUEST);
                } catch (Exception $e) {
                    $notification->push($e, 'horde.error');
                }
            }
        } catch (Exception $e) {
            $notification->push(sprintf(_("There was an error adding the event: %s"), $e->getMessage()), 'horde.error');
        }
    } catch (Exception $e) {
        $notification->push(sprintf(_("There was an error accessing the calendar: %s"), $e->getMessage()), 'horde.error');
    }
} while (false);
$url = Horde_Util::getFormData('url');
if (!empty($url)) {
    $url = new Horde_Url($url, true);
} else {
Esempio n. 5
0
 /**
  */
 public function davDeleteObject($collection, $object)
 {
     $dav = $GLOBALS['injector']->getInstance('Horde_Dav_Storage');
     $internal = $dav->getInternalCollectionId($collection, 'calendar') ?: $collection;
     if (!Kronolith::hasPermission($internal, Horde_Perms::DELETE)) {
         throw new Kronolith_Exception(_("Calendar does not exist or no permission to delete"));
     }
     try {
         $object = $dav->getInternalObjectId($object, $internal) ?: preg_replace('/\\.ics$/', '', $object);
     } catch (Horde_Dav_Exception $e) {
     }
     $kronolith_driver = Kronolith::getDriver(null, $internal);
     $event = $kronolith_driver->getEvent($object);
     $kronolith_driver->deleteEvent($object);
     try {
         $dav->deleteExternalObjectId($object, $internal);
     } catch (Horde_Dav_Exception $e) {
     }
     // Send iTip messages unless organizer is external.
     // Notifications will get lost, there is no way to return messages to
     // clients.
     if ($event->organizer && !Kronolith::isUserEmail($event->creator, $event->organizer)) {
         return;
     }
     Kronolith::sendITipNotifications($event, new Horde_Notification_Handler(new Horde_Notification_Storage_Object()), Kronolith::ITIP_CANCEL);
 }
Esempio n. 6
0
File: Dav.php Progetto: horde/horde
 protected function _postSave(Kronolith_Event $event)
 {
     global $registry;
     if (!$this->_dav->getInternalObjectId($this->_params['object'], $this->_calendar)) {
         $this->_dav->addObjectMap($event->id, $this->_params['object'], $this->_calendar);
     }
     // Send iTip messages if necessary.
     $type = Kronolith::ITIP_REQUEST;
     if ($event->organizer && !Kronolith::isUserEmail($event->creator, $event->organizer)) {
         $type = Kronolith::ITIP_REPLY;
     }
     $event_copy = clone $event;
     $event_copy->attendees = $event->attendees->without($this->_noItips);
     $notification = new Horde_Notification_Handler(new Horde_Notification_Storage_Object());
     Kronolith::sendITipNotifications($event_copy, $notification, $type);
     // Send ITIP_CANCEL to any attendee that was removed, but only if this
     // is the ORGANZIER's copy of the event.
     if (empty($event->organizer) || $registry->getAuth() == $event->creator && Kronolith::isUserEmail($event->creator, $event->organizer)) {
         $removed_attendees = new Kronolith_Attendee_List();
         foreach ($this->_oldAttendees as $old_attendee) {
             if (!$event->attendees->has($old_attendee)) {
                 $removed_attendees->add($old_attendee);
             }
         }
         if (count($removed_attendees)) {
             $cancelEvent = clone $event;
             Kronolith::sendITipNotifications($cancelEvent, $notification, Kronolith::ITIP_CANCEL, null, null, $removed_attendees);
         }
     }
 }