Ejemplo n.º 1
0
 public function onCommentAdd(OW_Event $e)
 {
     $params = $e->getParams();
     if ($params['entityType'] != EQUESTIONS_BOL_Service::ENTITY_TYPE) {
         return;
     }
     $questionId = (int) $params['entityId'];
     $comment = $this->service->findComment($params['commentId']);
     $event = new OW_Event(EQUESTIONS_BOL_Service::EVENT_POST_ADDED, array('questionId' => $questionId, 'id' => (int) $params['commentId'], 'userId' => (int) $params['userId'], 'text' => $comment->message));
     OW::getEventManager()->trigger($event);
 }
Ejemplo n.º 2
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);
 }