public function executeAdd() { $comment = new Comment(); $comment->setSnippet(SnippetPeer::retrieveByPk($this->getRequestParameter('id'))); if ($this->getUser()->isAuthenticated()) { $comment->setUserId($this->getUser()->getGuardUser()->getId()); } else { $comment->setName($this->getRequestParameter('name')); $comment->setEmail($this->getRequestParameter('email')); } $comment->setRawBody($this->getRequestParameter('raw_body')); $comment->save(); $this->comment = $comment; }
public function executeDelete() { $id = $this->getRequestParameter('id'); $this->forward404Unless($id); $snippet = SnippetPeer::retrieveByPk($id); $this->forward404Unless($snippet); if ($snippet->getUserId() != $this->getUser()->getGuardUser()->getId()) { $this->forward('default', 'secure'); } $snippet->delete(); $this->setFlash('info', 'Snippet is completely removed from the system.'); $this->forward('site', 'message'); }