Esempio n. 1
0
 /**
  * Constructor.
  *
  * @param BASE_CommentsParams $params
  */
 public function __construct(BASE_CommentsParams $params)
 {
     parent::__construct();
     $this->params = $params;
     $this->batchData = $params->getBatchData();
     $this->staticData = empty($this->batchData['_static']) ? array() : $this->batchData['_static'];
     $this->batchData = isset($this->batchData[$params->getEntityType()][$params->getEntityId()]) ? $this->batchData[$params->getEntityType()][$params->getEntityId()] : array();
     srand(time());
     $this->id = $params->getEntityType() . $params->getEntityId() . rand(1, 10000);
     $this->cmpContextId = "comments-{$this->id}";
     $this->assign('cmpContext', $this->cmpContextId);
     $this->assign('wrapInBox', $params->getWrapInBox());
     $this->assign('topList', in_array($params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI)));
     $this->assign('bottomList', $params->getDisplayType() == BASE_CommentsParams::DISPLAY_TYPE_WITH_PAGING);
     $this->assign('mini', $params->getDisplayType() == BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
     $this->isAuthorized = OW::getUser()->isAuthorized($params->getPluginKey(), 'add_comment') && $params->getAddComment();
     if (!$this->isAuthorized) {
         $errorMessage = $params->getErrorMessage();
         if (empty($errorMessage)) {
             $status = BOL_AuthorizationService::getInstance()->getActionStatus($params->getPluginKey(), 'add_comment');
             $errorMessage = OW::getUser()->isAuthenticated() ? $status['msg'] : OW::getLanguage()->text('base', 'comments_add_login_message');
         }
         $this->assign('authErrorMessage', $errorMessage);
     }
     $this->initForm();
 }
Esempio n. 2
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();
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * @param BASE_CommentsParams $params
  */
 public function __construct(BASE_CommentsParams $params)
 {
     parent::__construct();
     $this->params = $params;
     $this->batchData = $params->getBatchData();
     $this->staticData = empty($this->batchData['_static']) ? array() : $this->batchData['_static'];
     $this->batchData = isset($this->batchData[$params->getEntityType()][$params->getEntityId()]) ? $this->batchData[$params->getEntityType()][$params->getEntityId()] : array();
     srand(time());
     $this->id = $params->getEntityType() . $params->getEntityId() . rand(1, 10000);
     $this->cmpContextId = "comments-{$this->id}";
     $this->formName = "comment-add-{$this->id}";
     $this->assign('cmpContext', $this->cmpContextId);
     $this->assign('wrapInBox', $params->getWrapInBox());
     $this->isAuthorized = OW::getUser()->isAuthorized($params->getPluginKey(), 'add_comment') && $params->getAddComment();
     if (!$this->isAuthorized) {
         $errorMessage = $params->getErrorMessage();
         if (empty($errorMessage)) {
             $errorMessage = OW::getLanguage()->text('base', OW::getUser()->isAuthenticated() ? 'comments_add_auth_message' : 'comments_add_login_message');
         }
         $this->assign('authErrorMessage', $errorMessage);
     } else {
         $eventParams = array('pluginKey' => $params->getPluginKey(), 'action' => 'add_comment');
         if (isset($this->staticData['credits'][$params->getPluginKey()])) {
             $credits = $this->staticData['credits'][$params->getPluginKey()];
         } else {
             $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
         }
         if ($credits === false) {
             $this->isAuthorized = false;
             $this->assign('authErrorMessage', OW::getEventManager()->call('usercredits.error_message', $eventParams));
         } else {
             //
         }
     }
     $this->initForm();
 }