if (Kronolith_Resource::isResourceCalendar($c = Horde_Util::getFormData('calendar'))) {
$driver = 'Resource';
} else {
- $driver = null;
+ $driver = Horde_Util::getFormData('type');
}
$kronolith_driver = Kronolith::getDriver($driver, $c);
$url->redirect();
}
if ($driver != 'Resource') {
- $share = $kronolith_shares->getShare($event->calendar);
- if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE, $event->creator)) {
- $notification->push(_("You do not have permission to delete this event."), 'horde.warning');
- } else {
+ if ($driver == 'remote') {
+ /* The remote server is doing the permission checks for us. */
$have_perms = true;
+ } else {
+ $share = $kronolith_shares->getShare($event->calendar);
+ if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE, $event->creator)) {
+ $notification->push(_("You do not have permission to delete this event."), 'horde.warning');
+ } else {
+ $have_perms = true;
+ }
}
} else {
if (!$registry->isAdmin()) {
}
/**
+ * Deletes an event.
+ *
+ * @param string $eventId The ID of the event to delete.
+ * @param boolean $silent Don't send notifications, used when deleting
+ * events in bulk from maintenance tasks.
+ *
+ * @throws Kronolith_Exception
+ * @throws Horde_Exception_NotFound
+ * @throws Horde_Mime_Exception
+ */
+ public function deleteEvent($eventId, $silent = false)
+ {
+ if (!$this->isCalDAV()) {
+ throw new Kronolith_Exception(_("Deleting events is not supported with this remote calendar."));
+ }
+
+ if (preg_match('/(.*)-(\d+)$/', $eventId, $matches)) {
+ throw new Kronolith_Exception(_("Cannot delete exceptions (yet)."));
+ }
+
+ $url = trim($this->_getUrl(), '/') . '/' . $eventId;
+ try {
+ $response = $this->_getClient()->delete($url);
+ } catch (Horde_Http_Exception $e) {
+ Horde::logMessage($e, 'INFO');
+ throw new Kronolith_Exception($e);
+ }
+ if (!in_array($response->code, array(200, 202, 204))) {
+ Horde::logMessage(sprintf('Failed to delete event from remote calendar: url = "%s", status = %s',
+ $url, $response->code), 'INFO');
+ throw new Kronolith_Exception(_("The event could not be deleted from the remote server."));
+ }
+ }
+
+ /**
* Fetches a remote calendar into the session and return the data.
*
* @param boolean $cache Whether to return data from the session cache.
<input type="hidden" name="url" value="<?php echo htmlspecialchars($url) ?>" />
<input type="hidden" name="eventID" value="<?php echo htmlspecialchars($this->event->id) ?>" />
<input type="hidden" name="calendar" value="<?php echo htmlspecialchars($this->event->calendar) ?>" />
+<input type="hidden" name="type" value="<?php echo htmlspecialchars($this->event->calendarType) ?>" />
<table class="striped" cellspacing="0">
<tr><td class="warning"><?php echo _("This is a recurring event. Delete the current event only, this<br />occurrence and all future occurences, or all occurences?") ?></td></tr>
<input type="hidden" name="url" value="<?php echo htmlspecialchars($url) ?>" />
<input type="hidden" name="eventID" value="<?php echo htmlspecialchars($this->event->id) ?>" />
<input type="hidden" name="calendar" value="<?php echo htmlspecialchars(Horde_Util::getFormData('calendar')) ?>" />
+<input type="hidden" name="type" value="<?php echo htmlspecialchars($this->event->calendarType) ?>" />
<div class="headerbox">
<?php if (!empty($this->event->attendees)): ?>