/** * (Dis)allows post for viewing * * @Privilege("show") * * @param int $id Guestbook post ID */ public function handleShow($id) { $news = $this->guestbook->showPost($id); if ($news->show) { $this->flashMessage("Příspěvek byl zobrazen"); } else { $this->flashMessage("Příspěvek byl odzobrazen"); } $this->redirect('Guestbook:'); }
/** * Processes the Guestbook form * * @param \Nette\Application\Ui\Form $form Form to be processed */ public function guestBookFormSucceeded(\Nette\Application\Ui\Form $form) { $values = $form->getValues(TRUE); unset($values['send']); unset($values['spam']); unset($values['form_created']); if ($this->user->isLoggedIn()) { $values['user_id'] = $this->user->id; } $values['time'] = new \Nette\Utils\DateTime(); $this->guestbook->insert($values); $this->flashMessage('Zpráva byla odeslána'); $this->redirect('this'); }