Exemple #1
0
 public function post_user_actions()
 {
     if (!$this->checkCsrfToken()) {
         return $this->response->setData(['error' => _i('The security token was not found. Please try again.')]);
     }
     if (!$this->check_board()) {
         return $this->response->setData(['error' => _i('No board was selected.')])->setStatusCode(422);
     }
     if ($this->getPost('action') === 'report') {
         try {
             $this->report_coll->add($this->radix, $this->getPost('doc_id'), $this->getPost('reason'), Inet::ptod($this->getRequest()->getClientIp()));
         } catch (\Foolz\Foolfuuka\Model\ReportException $e) {
             return $this->response->setData(['error' => $e->getMessage()]);
         }
         return $this->response->setData(['success' => _i('You have successfully submitted a report for this post.')]);
     }
     /*
     if ($this->getPost('action') === 'report_media') {
         try {
             $this->report_coll->add($this->radix, $this->getPost('media_id'), $this->getPost('reason'), null, 'media_id');
         } catch (\Foolz\Foolfuuka\Model\ReportException $e) {
             return $this->response->setData(['error' => $e->getMessage()]);
         }
     
         return $this->response->setData(['success' => _i('This media was reported.')]);
     }
     */
     if ($this->getPost('action') === 'delete') {
         try {
             $comments = Board::forge($this->getContext())->getPost()->setOptions('doc_id', $this->getPost('doc_id'))->setCommentOptions('clean', false)->setRadix($this->radix)->getComments();
             $comment = current($comments);
             $comment = new Comment($this->getContext(), $comment);
             $comment->delete($this->getPost('password'));
         } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
             return $this->response->setData(['error' => $e->getMessage()]);
         } catch (\Foolz\Foolfuuka\Model\CommentDeleteWrongPassException $e) {
             return $this->response->setData(['error' => $e->getMessage()]);
         }
         return $this->response->setData(['success' => _i('This post was deleted.')]);
     }
 }