Exemple #1
0
 public function getReports()
 {
     if ($this->reports === null) {
         if ($this->getAuth()->hasAccess('comment.reports')) {
             $reports = $this->report_coll->getByDocId($this->radix, $this->comment->doc_id);
             if ($this->bulk->media) {
                 $reports += $this->report_coll->getByMediaId($this->radix, $this->bulk->media->media_id);
             }
             $this->reports = $reports;
         } else {
             $this->reports = [];
         }
     }
     return $this->reports;
 }
Exemple #2
0
 /**
  * Returns the Comment by doc_id or the first Comment found with a matching media_id
  *
  * @return  null|\Foolz\FoolFuuka\Model\CommentBulk
  * @throws  \Foolz\FoolFuuka\Model\ReportMediaNotFoundException
  * @throws  \Foolz\FoolFuuka\Model\ReportCommentNotFoundException
  */
 public function p_getComment()
 {
     if ($this->media_id !== null) {
         // custom "get the first doc_id with the media"
         $doc_id_res = $this->dc->qb()->select('doc_id')->from($this->radix_coll->getById($this->board_id)->getTable(), 'a')->where('media_id = :media_id')->orderBy('timestamp', 'desc')->setParameter('media_id', $this->media_id)->execute()->fetch();
         if ($doc_id_res !== null) {
             $this->doc_id = $doc_id_res->doc_id;
         } else {
             $this->report_coll->delete($this->id);
             return null;
         }
     }
     try {
         $comments = Board::forge($this->getContext())->getPost()->setRadix($this->radix)->setOptions('doc_id', $this->doc_id)->getComments();
         $this->comment = current($comments);
     } catch (BoardException $e) {
         $this->report_coll->delete($this->id);
         return null;
     }
     return $this->comment;
 }
Exemple #3
0
 public function post_mod_actions()
 {
     if (!$this->checkCsrfToken()) {
         return $this->response->setData(['error' => _i('The security token was not found. Please try again.')]);
     }
     if (!$this->getAuth()->hasAccess('comment.mod_capcode')) {
         return $this->response->setData(['error' => _i('Access Denied.')])->setStatusCode(403);
     }
     if (!$this->check_board()) {
         return $this->response->setData(['error' => _i('No board was selected.')])->setStatusCode(422);
     }
     if ($this->getPost('action') === 'delete_report') {
         try {
             $this->report_coll->delete($this->getPost('id'));
         } catch (\Foolz\Foolfuuka\Model\ReportException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('The report was deleted.')]);
     }
     if ($this->getPost('action') === 'delete_post') {
         try {
             $comments = Board::forge($this->getContext())->getPost()->setOptions('doc_id', $this->getPost('id'))->setRadix($this->radix)->getComments();
             $comment = current($comments);
             $comment = new Comment($this->getContext(), $comment);
             $comment->delete();
         } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This post was deleted.')]);
     }
     if ($this->getPost('action') === 'delete_image') {
         try {
             $media = $this->media_factory->getByMediaId($this->radix, $this->getPost('id'));
             $media = new Media($this->getContext(), CommentBulk::forge($this->radix, null, $media));
             $media->delete(true, true, true);
         } catch (\Foolz\Foolfuuka\Model\MediaNotFoundException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This image was deleted.')]);
     }
     if ($this->getPost('action') === 'ban_image_local' || $this->getPost('action') === 'ban_image_global') {
         $global = false;
         if ($this->getPost('action') === 'ban_image_global') {
             $global = true;
         }
         try {
             $media = $this->media_factory->getByMediaId($this->radix, $this->getPost('id'));
             $media = new Media($this->getContext(), CommentBulk::forge($this->radix, null, $media));
             $media->ban($global);
         } catch (\Foolz\Foolfuuka\Model\MediaNotFoundException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This image was banned.')]);
     }
     if ($this->getPost('action') === 'ban_user') {
         try {
             $this->ban_factory->add(Inet::ptod($this->getPost('ip')), $this->getPost('reason'), $this->getPost('length'), $this->getPost('board_ban') === 'global' ? array() : array($this->radix->id));
         } catch (\Foolz\Foolfuuka\Model\BanException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This user was banned.')]);
     }
 }