/** * Parse the form */ protected function parse() { parent::parse(); // assign the data $this->tpl->assign('item', $this->record); $this->tpl->assign('showAgendaDeleteCategory', BackendAgendaModel::deleteCategoryAllowed($this->id) && BackendAuthentication::isAllowedAction('DeleteCategory')); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendAgendaModel::existsCategory($this->id)) { $this->record = (array) BackendAgendaModel::getCategory($this->id); if (BackendAgendaModel::deleteCategoryAllowed($this->id)) { parent::execute(); // delete item BackendAgendaModel::deleteCategory($this->id); BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record)); // category was deleted, so redirect $this->redirect(BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title'])); } } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing'); } }