/** * @throws Kronolith_Exception */ public function execute() { if ($this->_vars->get('submitbutton') == _("Cancel")) { Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect(); } Kronolith::deleteShare($this->_calendar); }
/** * TODO */ public function deleteCalendar() { $calendar_id = $this->vars->calendar; $result = new stdClass(); switch ($this->vars->type) { case 'internal': try { $calendar = $GLOBALS['injector']->getInstance('Kronolith_Shares')->getShare($calendar_id); } catch (Exception $e) { $GLOBALS['notification']->push($e, 'horde.error'); return $result; } try { Kronolith::deleteShare($calendar); } catch (Exception $e) { $GLOBALS['notification']->push(sprintf(_("Unable to delete \"%s\": %s"), $calendar->get('name'), $e->getMessage()), 'horde.error'); return $result; } $GLOBALS['notification']->push(sprintf(_("The calendar \"%s\" has been deleted."), $calendar->get('name')), 'horde.success'); break; case 'tasklists': $calendar_id = substr($calendar_id, 6); $tasklists = $GLOBALS['registry']->tasks->listTasklists(true); if (!isset($tasklists[$calendar_id])) { $GLOBALS['notification']->push(_("You are not allowed to delete this task list."), 'horde.error'); return $result; } try { $GLOBALS['registry']->tasks->deleteTasklist($calendar_id); } catch (Exception $e) { $GLOBALS['notification']->push(sprintf(_("Unable to delete \"%s\": %s"), $tasklists[$calendar_id]->get('name'), $e->getMessage()), 'horde.error'); return $result; } $GLOBALS['notification']->push(sprintf(_("The task list \"%s\" has been deleted."), $tasklists[$calendar_id]->get('name')), 'horde.success'); break; case 'remote': try { $deleted = Kronolith::unsubscribeRemoteCalendar($calendar_id); } catch (Exception $e) { $GLOBALS['notification']->push($e, 'horde.error'); return $result; } $GLOBALS['notification']->push(sprintf(_("You have been unsubscribed from \"%s\" (%s)."), $deleted['name'], $deleted['url']), 'horde.success'); break; case 'resource': try { $rdriver = Kronolith::getDriver('Resource'); $resource = $rdriver->getResource($rdriver->getResourceIdByCalendar($calendar_id)); if (!$resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $GLOBALS['notification']->push(_("You are not allowed to delete this resource."), 'horde.error'); return $result; } $name = $resource->get('name'); $rdriver->delete($resource); } catch (Kronolith_Exception $e) { $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); return $result; } $GLOBALS['notification']->push(sprintf(_("The resource \"%s\" has been deleted."), $name), 'horde.success'); break; case 'resourcegroup': try { $rdriver = Kronolith::getDriver('Resource'); $resource = $rdriver->getResource($calendar_id); if (!$resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $GLOBALS['notification']->push(_("You are not allowed to delete this resource."), 'horde.error'); return $result; } $name = $resource->get('name'); $rdriver->delete($resource); } catch (Kronolith_Exception $e) { $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); return $result; } $GLOBALS['notification']->push(sprintf(_("The resource \"%s\" has been deleted."), $name), 'horde.success'); } $result->deleted = true; return $result; }
/** * Delete the specified calendar. * * @param string $id The calendar id. */ public function deleteCalendar($id) { $calendar = $GLOBALS['injector']->getInstance('Kronolith_Shares')->getShare($calendar); Kronolith::deleteShare($calendar); }