Ejemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param string $entityType
  * @param integer $entityId
  * @param integer $page
  * @param string $displayType
  */
 public function __construct(BASE_CommentsParams $params, $id, $page = 1)
 {
     parent::__construct();
     $batchData = $params->getBatchData();
     $this->staticData = empty($batchData['_static']) ? array() : $batchData['_static'];
     $batchData = isset($batchData[$params->getEntityType()][$params->getEntityId()]) ? $batchData[$params->getEntityType()][$params->getEntityId()] : array();
     $this->params = $params;
     $this->batchData = $batchData;
     $this->id = $id;
     $this->page = $page;
     $this->isModerator = OW::getUser()->isAuthorized($params->getPluginKey());
     $this->isOwnerAuthorized = OW::getUser()->isAuthenticated() && $this->params->getOwnerId() !== null && (int) $this->params->getOwnerId() === (int) OW::getUser()->getId();
     $this->isBaseModerator = OW::getUser()->isAuthorized('base');
     $this->commentService = BOL_CommentService::getInstance();
     $this->avatarService = BOL_AvatarService::getInstance();
     $this->cmpContextId = "comments-list-{$id}";
     $this->assign('cmpContext', $this->cmpContextId);
     $this->commentCount = isset($batchData['commentsCount']) ? $batchData['commentsCount'] : $this->commentService->findCommentCount($params->getEntityType(), $params->getEntityId());
     $this->init();
 }
Ejemplo n.º 2
0
 public function deleteComment()
 {
     $commentArray = $this->getCommentInfoForDelete();
     $comment = $commentArray['comment'];
     $commentEntity = $commentArray['commentEntity'];
     $this->deleteAttachmentFiles($comment);
     $this->commentService->deleteComment($comment->getId());
     $commentCount = $this->commentService->findCommentCount($commentEntity->getEntityType(), $commentEntity->getEntityId());
     if ($commentCount === 0) {
         $this->commentService->deleteCommentEntity($commentEntity->getId());
     }
     $event = new OW_Event('base_delete_comment', array('entityType' => $commentEntity->getEntityType(), 'entityId' => $commentEntity->getEntityId(), 'userId' => $comment->getUserId(), 'commentId' => $comment->getId()));
     OW::getEventManager()->trigger($event);
     $this->getCommentList();
 }