/** * @param int $id */ public function actionEdit($id) { if (!$this->user->isAllowed('Article', 'edit')) { throw new ForbiddenRequestException(); } $this->article = $this->articleManager->get($id); $this->template->articleDetail = $this->article; if (isset($this->article->id) && $this->article->id > 0) { if ($this->user->id == $this->article->user->id) { $this->template->article = $this->article; } else { throw new ForbiddenRequestException(); } } else { throw new BadRequestException(); } }
public function actionDefault($id, $slug = '') { $this->articleDetail = $this->articleManager->get($id); if (!$this->articleDetail) { throw new BadRequestException(); } if ($this->articleDetail->document_state == 'draft') { if (!$this->user->isLoggedIn()) { throw new ForbiddenRequestException(); } if ($this->user->getId() != $this->articleDetail->user_id) { throw new ForbiddenRequestException(); } } if ($slug != $this->articleDetail->slug || $this->language != $this->articleDetail->language) { $this->redirect(303, 'Detail:default', [$id, $this->articleDetail->slug, 'language' => $this->articleDetail->language]); } }
/** * @param int $id */ public function handleDelete($id) { if ($this->user->isAllowed('Article', 'edit')) { $this->article = $this->articleManager->get($id); if ($this->article) { $this->articleManager->deleteArticle($id); $this->flashMessage('Article was removed'); $this->redrawControl('flashes'); // $this->redrawControl('datalist'); } } if (!$this->isAjax()) { $this->redirect('this'); } }