/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendBlogModel::exists($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // set category id $this->categoryId = SpoonFilter::getGetValue('category', null, null, 'int'); if ($this->categoryId == 0) { $this->categoryId = null; } // get data $this->record = (array) BackendBlogModel::get($this->id); // delete item BackendBlogModel::delete($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); // delete search indexes if (is_callable(array('BackendSearchModel', 'removeIndex'))) { BackendSearchModel::removeIndex($this->getModule(), $this->id); } // build redirect URL $redirectUrl = BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']); // append to redirect URL if ($this->categoryId != null) { $redirectUrl .= '&category=' . $this->categoryId; } // item was deleted, so redirect $this->redirect($redirectUrl); } else { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * Get the data * If a revision-id was specified in the URL we load the revision and not the actual data. */ private function getData() { $this->record = (array) BackendBlogModel::get($this->id); $this->imageIsAllowed = BackendModel::getModuleSetting($this->URL->getModule(), 'show_image_form', true); // is there a revision specified? $revisionToLoad = $this->getParameter('revision', 'int'); // if this is a valid revision if ($revisionToLoad !== null) { // overwrite the current record $this->record = (array) BackendBlogModel::getRevision($this->id, $revisionToLoad); // show warning $this->tpl->assign('usingRevision', true); } // is there a revision specified? $draftToLoad = $this->getParameter('draft', 'int'); // if this is a valid revision if ($draftToLoad !== null) { // overwrite the current record $this->record = (array) BackendBlogModel::getRevision($this->id, $draftToLoad); // show warning $this->tpl->assign('usingDraft', true); // assign draft $this->tpl->assign('draftId', $draftToLoad); } // no item found, throw an exceptions, because somebody is f*****g with our URL if (empty($this->record)) { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }