Esempio n. 1
0
 public function addComment($postId)
 {
     if (!$this->auth->guest()) {
         $comment = new Comment();
         $comment->setAuthor($_SESSION['user']);
         $comment->setText($this->app->request->post("text"));
         $comment->setDate(date("dmY"));
         $comment->setPost($postId);
         $comment->setAnsDoc($this->app->request->post('ansdoc'));
         $this->commentRepository->save($comment);
         $this->app->redirect('/posts/' . $postId);
     } else {
         $this->app->redirect('/login');
         $this->app->flash('info', 'you must log in to do that');
     }
 }