Check for resource declines and push notice to stack if found.
public static notifyOfResourceRejection ( Kronolith_Event $event ) | ||
$event | Kronolith_Event |
/** * 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); }
/** * Update event details as a result of a drag/drop operation (which would * only affect the event's start/end times). * * Uses the following request variables: *<pre> * -cal: The calendar id. * -id: The event id. * -att: Attribute hash of changed values. Can contain: * -start: A new start datetime for the event. * -end: A new end datetime for the event. * -offDays: An offset of days to apply to the event. * -offMins: An offset of minutes to apply to the event. * -rstart: The orginal start datetime of a series instance. * -rend: The original end datetime of a series instance. * -rday: A new start value for a series instance (used when * dragging on the month view where only the date can * change, and not the start/end times). * -u: Send update to attendees. *</pre> */ public function updateEvent() { $result = $this->_signedResponse($this->vars->cal); if (!($kronolith_driver = $this->_getDriver($this->vars->cal)) || !isset($this->vars->id)) { return $result; } try { $oevent = $kronolith_driver->getEvent($this->vars->id); } catch (Exception $e) { $GLOBALS['notification']->push($e, 'horde.error'); return $result; } if (!$oevent) { $GLOBALS['notification']->push(_("The requested event was not found."), 'horde.error'); return $result; } elseif (!$oevent->hasPermission(Horde_Perms::EDIT)) { $GLOBALS['notification']->push(_("You do not have permission to edit this event."), 'horde.warning'); return $result; } $attributes = Horde_Serialize::unserialize($this->vars->att, Horde_Serialize::JSON); // If this is a recurring event, need to create an exception. if ($oevent->recurs()) { $this->_addException($oevent, $attributes); $event = $this->_copyEvent($oevent, null, $attributes); } else { $event = clone $oevent; } foreach ($attributes as $attribute => $value) { switch ($attribute) { case 'start': $newDate = new Horde_Date($value); $newDate->setTimezone($event->start->timezone); $event->start = clone $newDate; break; case 'end': $newDate = new Horde_Date($value); $newDate->setTimezone($event->end->timezone); $event->end = clone $newDate; if ($event->end->hour == 23 && $event->end->min == 59 && $event->end->sec == 59) { $event->end->mday++; $event->end->hour = $event->end->min = $event->end->sec = 0; } break; case 'offDays': $event->start->mday += $value; $event->end->mday += $value; break; case 'offMins': $event->start->min += $value; $event->end->min += $value; break; } } $result = $this->_saveEvent($event, $oevent->recurs() ? $oevent : null, $attributes); if ($this->vars->u) { Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_REQUEST); } Kronolith::notifyOfResourceRejection($event); return $result; }
break; } if ($user != $GLOBALS['registry']->getAuth() && !$kronolith_calendar->hasPermission(Kronolith::PERMS_DELEGATE)) { $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');
/** * Save a new or update an existing event from the AJAX event detail view. * * Request parameters used: * - event: The event id. * - cal: The calendar id. * - targetcalendar: If moving events, the targetcalendar to move to. * - as_new: Save an existing event as a new event. * - recur_edit: If editing an instance of a recurring event series, * how to apply the edit [current|future|all]. * - rstart: If editing an instance of a recurring event series, * the original start datetime of this instance. * - rend: If editing an instance of a recurring event series, * the original ending datetime of this instance. * - sendupdates: Should updates be sent to attendees? * - cstart: Start time of the client cache. * - cend: End time of the client cache. */ public function saveEvent() { $result = $this->_signedResponse($this->vars->targetcalendar); if (!($kronolith_driver = $this->_getDriver($this->vars->targetcalendar))) { return $result; } if ($this->vars->as_new) { unset($this->vars->event); } if (!$this->vars->event) { $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'))); return $result; } } if ($this->vars->event && $this->vars->cal && $this->vars->cal != $this->vars->targetcalendar) { if (strpos($kronolith_driver->calendar, '\\')) { list($target, $user) = explode('\\', $kronolith_driver->calendar, 2); } else { $target = $kronolith_driver->calendar; $user = $GLOBALS['registry']->getAuth(); } $kronolith_driver = $this->_getDriver($this->vars->cal); // Only delete the event from the source calendar if this user has // permissions to do so. try { $sourceShare = Kronolith::getInternalCalendar($kronolith_driver->calendar); $share = Kronolith::getInternalCalendar($target); if ($sourceShare->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE) && ($user == $GLOBALS['registry']->getAuth() && $share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT) || $user != $GLOBALS['registry']->getAuth() && $share->hasPermission($GLOBALS['registry']->getAuth(), Kronolith::PERMS_DELEGATE))) { $kronolith_driver->move($this->vars->event, $target); $kronolith_driver = $this->_getDriver($this->vars->targetcalendar); } } catch (Exception $e) { $GLOBALS['notification']->push(sprintf(_("There was an error moving the event: %s"), $e->getMessage()), 'horde.error'); return $result; } } if ($this->vars->as_new) { $event = $kronolith_driver->getEvent(); } else { try { $event = $kronolith_driver->getEvent($this->vars->event); } catch (Horde_Exception_NotFound $e) { $GLOBALS['notification']->push(_("The requested event was not found."), 'horde.error'); return $result; } catch (Exception $e) { $GLOBALS['notification']->push($e); return $result; } } if (!$event->hasPermission(Horde_Perms::EDIT)) { $GLOBALS['notification']->push(_("You do not have permission to edit this event."), 'horde.warning'); return $result; } if ($this->vars->recur_edit && $this->vars->recur_edit != 'all') { switch ($this->vars->recur_edit) { case 'current': $attributes = new stdClass(); $attributes->rstart = $this->vars->rstart; $attributes->rend = $this->vars->rend; $this->_addException($event, $attributes); // Create a copy of the original event so we can read in the new // form values for the exception. We also MUST reset the recurrence // property even though we won't be using it, since clone() does not // do a deep copy. Otherwise, the original event's recurrence will // become corrupt. $newEvent = clone $event; $newEvent->recurrence = new Horde_Date_Recurrence($event->start); $newEvent->readForm(); // Create an exception event from the new properties. $exception = $this->_copyEvent($event, $newEvent, $attributes); $exception->start = $newEvent->start; $exception->end = $newEvent->end; // Save the new exception. $attributes->cstart = $this->vars->cstart; $attributes->cend = $this->vars->cend; $result = $this->_saveEvent($exception, $event, $attributes); break; case 'future': $instance = new Horde_Date($this->vars->rstart, $event->timezone); $exception = clone $instance; $exception->mday--; if ($event->end->compareDate($exception) > 0) { // Same as 'all' since this is the first recurrence. $this->vars->recur_edit = 'all'; return $this->saveEvent(); } else { $event->recurrence->setRecurEnd($exception); $newEvent = $kronolith_driver->getEvent(); $newEvent->readForm(); $newEvent->uid = null; $result = $this->_saveEvent($newEvent, $event, $this->vars, true); } } } else { try { $event->readForm(); $result = $this->_saveEvent($event); } catch (Exception $e) { $GLOBALS['notification']->push($e); return $result; } } if ($result !== true && $this->vars->sendupdates) { $type = $event->status == Kronolith::STATUS_CANCELLED ? Kronolith::ITIP_CANCEL : Kronolith::ITIP_REQUEST; Kronolith::sendITipNotifications($event, $GLOBALS['notification'], $type); } Kronolith::notifyOfResourceRejection($event); return $result; }