Ejemplo n.º 1
0
 private function getCommentInfoForDelete()
 {
     if (!isset($_POST['commentId']) || (int) $_POST['commentId'] < 1) {
         echo json_encode(array('error' => OW::getLanguage()->text('base', 'comment_ajax_error')));
         exit;
     }
     /* @var $comment BOL_Comment */
     $comment = $this->commentService->findComment((int) $_POST['commentId']);
     /* @var $commentEntity BOL_CommentEntity */
     $commentEntity = $this->commentService->findCommentEntityById($comment->getCommentEntityId());
     if ($comment === null || $commentEntity === null) {
         echo json_encode(array('error' => OW::getLanguage()->text('base', 'comment_ajax_error')));
         exit;
     }
     $params = $this->getParamsObject();
     $isModerator = OW::getUser()->isAuthorized($params->getPluginKey());
     $isOwnerAuthorized = OW::getUser()->isAuthenticated() && $params->getOwnerId() !== null && (int) $params->getOwnerId() === (int) OW::getUser()->getId();
     $commentOwner = (int) OW::getUser()->getId() === (int) $comment->getUserId();
     if (!$isModerator && !$isOwnerAuthorized && !$commentOwner) {
         echo json_encode(array('error' => OW::getLanguage()->text('base', 'auth_ajax_error')));
         exit;
     }
     return array('comment' => $comment, 'commentEntity' => $commentEntity);
 }