コード例 #1
0
ファイル: comments.php プロジェクト: hardikamutech/loov
 /**
  * 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();
 }
コード例 #2
0
ファイル: comments.php プロジェクト: vazahat/dudex
 /**
  * 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();
 }