Procházet zdrojové kódy

Ticket #4209 - Comments: View block issues for members without profile.

AntonLV před 3 roky
rodič
revize
e71090ea54
1 změnil soubory, kde provedl 23 přidání a 20 odebrání
  1. 23 20
      template/scripts/BxBaseCmts.php

+ 23 - 20
template/scripts/BxBaseCmts.php

@@ -251,19 +251,13 @@ class BxBaseCmts extends BxDolCmts
      * @param array $aDp - display params array
      * @param array $aDp - display params array
      *
      *
      */
      */
-    function getComments($aBp = array(), $aDp = array())
+    function getComments($aBp = [], $aDp = [])
     {
     {
         $this->_prepareParams($aBp, $aDp);
         $this->_prepareParams($aBp, $aDp);
 
 
         $aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp[($aBp['init_view'] != -1 ? 'init' : 'per') . '_view']);
         $aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp[($aBp['init_view'] != -1 ? 'init' : 'per') . '_view']);
-        if(empty($aCmts) || !is_array($aCmts)) {
-            if((int)$aBp['parent_id'] == 0 && !$this->isPostAllowed()) {
-                $oPermalink = BxDolPermalinks::getInstance();
-                return MsgBox(_t('_cmt_msg_login_required', $oPermalink->permalink('page.php?i=login'), $oPermalink->permalink('page.php?i=create-account')));
-            }
-
+        if(empty($aCmts) || !is_array($aCmts))
             return isset($aDp['show_empty']) && $aDp['show_empty'] === true ? $this->_getEmpty($aDp) : '';
             return isset($aDp['show_empty']) && $aDp['show_empty'] === true ? $this->_getEmpty($aDp) : '';
-        }
 
 
         $sCmts = '';
         $sCmts = '';
         foreach($aCmts as $k => $aCmt)
         foreach($aCmts as $k => $aCmt)
@@ -273,7 +267,7 @@ class BxBaseCmts extends BxDolCmts
         return $sCmts;
         return $sCmts;
     }
     }
 
 
-    function getCommentsPinned($aBp = array(), $aDp = array())
+    function getCommentsPinned($aBp = [], $aDp = [])
     {
     {
         $this->_prepareParams($aBp, $aDp);
         $this->_prepareParams($aBp, $aDp);
 
 
@@ -1052,7 +1046,7 @@ class BxBaseCmts extends BxDolCmts
 
 
         $aForm = $this->{'_getForm' . ucfirst($sType)}($iCmtParentId, $aDp);
         $aForm = $this->{'_getForm' . ucfirst($sType)}($iCmtParentId, $aDp);
         if(empty($aForm['form']))
         if(empty($aForm['form']))
-            return !empty($aForm['msg']) && (isLogged() || $iCmtParentId != 0 || $this->getCommentsCount() > 0) ? MsgBox($aForm['msg']) : '';
+            return !empty($aForm['msg']) ? MsgBox($aForm['msg']) : '';
 
 
         return $this->_oTemplate->parseHtmlByName('comment_reply_box.html', array(
         return $this->_oTemplate->parseHtmlByName('comment_reply_box.html', array(
             'js_object' => $this->_sJsObjName,
             'js_object' => $this->_sJsObjName,
@@ -1141,11 +1135,20 @@ class BxBaseCmts extends BxDolCmts
     protected function _getFormPost($iCmtParentId = 0, $aDp = [])
     protected function _getFormPost($iCmtParentId = 0, $aDp = [])
     {
     {
         $bCmtParentId = !empty($iCmtParentId);
         $bCmtParentId = !empty($iCmtParentId);
-        if(!$bCmtParentId && !$this->isPostAllowed())
-            return array('msg' => $this->msgErrPostAllowed());
+        if(!$bCmtParentId && !$this->isPostAllowed()) {
+            $sMsg = '';
+            if(!isLogged()) {
+                $oPermalink = BxDolPermalinks::getInstance();
+                $sMsg = _t('_cmt_msg_login_required', $oPermalink->permalink('page.php?i=login'), $oPermalink->permalink('page.php?i=create-account'));
+            }
+            else
+                $sMsg = $this->msgErrPostAllowed();
+
+            return ['msg' => $sMsg];
+        }
 
 
         if($bCmtParentId && !$this->isReplyAllowed($iCmtParentId))
         if($bCmtParentId && !$this->isReplyAllowed($iCmtParentId))
-            return array('msg' => $this->msgErrReplyAllowed());
+            return ['msg' => $this->msgErrReplyAllowed()];
 
 
         $bDynamic = isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'];
         $bDynamic = isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'];
         $bQuote = isset($aDp['quote']) && (bool)$aDp['quote'];
         $bQuote = isset($aDp['quote']) && (bool)$aDp['quote'];
@@ -1156,9 +1159,9 @@ class BxBaseCmts extends BxDolCmts
         if($bQuote) {
         if($bQuote) {
             $aCmtParent = $this->getCommentRow((int)$iCmtParentId);
             $aCmtParent = $this->getCommentRow((int)$iCmtParentId);
             if(!empty($aCmtParent['cmt_text']))
             if(!empty($aCmtParent['cmt_text']))
-                $oForm->aInputs['cmt_text']['value'] = $this->_oTemplate->parseHtmlByName('comment_quote.html', array(
+                $oForm->aInputs['cmt_text']['value'] = $this->_oTemplate->parseHtmlByName('comment_quote.html', [
                     'content' => $aCmtParent['cmt_text']
                     'content' => $aCmtParent['cmt_text']
-                ));
+                ]);
         }
         }
 
 
         $oForm->initChecker();
         $oForm->initChecker();
@@ -1178,10 +1181,10 @@ class BxBaseCmts extends BxDolCmts
                 $oForm->aInputs['cmt_text']['error'] =  _t('_Please enter characters');
                 $oForm->aInputs['cmt_text']['error'] =  _t('_Please enter characters');
                 $oForm->setValid(false);
                 $oForm->setValid(false);
 
 
-            	return array('form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id);
+            	return ['form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id];
             }
             }
 
 
-            $aParent = array();
+            $aParent = [];
             if($iCmtParentId > 0) {
             if($iCmtParentId > 0) {
                 $aParent = $this->getCommentRow($iCmtParentId);
                 $aParent = $this->getCommentRow($iCmtParentId);
                 if(empty($aParent) || !is_array($aParent)) {
                 if(empty($aParent) || !is_array($aParent)) {
@@ -1197,7 +1200,7 @@ class BxBaseCmts extends BxDolCmts
                 $iCmtVisualParentId = $iLevel > $this->getMaxLevel() ? $aParent['cmt_vparent_id'] : $iCmtParentId;
                 $iCmtVisualParentId = $iLevel > $this->getMaxLevel() ? $aParent['cmt_vparent_id'] : $iCmtParentId;
             }
             }
 
 
-            $iCmtId = (int)$oForm->insert(array('cmt_vparent_id' => $iCmtVisualParentId, 'cmt_object_id' => $this->_iId, 'cmt_author_id' => $iCmtAuthorId, 'cmt_level' => $iLevel, 'cmt_time' => time()));
+            $iCmtId = (int)$oForm->insert(['cmt_vparent_id' => $iCmtVisualParentId, 'cmt_object_id' => $this->_iId, 'cmt_author_id' => $iCmtAuthorId, 'cmt_level' => $iLevel, 'cmt_time' => time()]);
             if($iCmtId != 0) {
             if($iCmtId != 0) {
                 $iCmtUniqId = $this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId, [
                 $iCmtUniqId = $this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId, [
                     'author_id' => $iCmtAuthorId,
                     'author_id' => $iCmtAuthorId,
@@ -1228,10 +1231,10 @@ class BxBaseCmts extends BxDolCmts
                     return $mixedResult;
                     return $mixedResult;
             }
             }
 
 
-            return array('msg' => _t('_cmt_err_cannot_perform_action'));
+            return ['msg' => _t('_cmt_err_cannot_perform_action')];
         }
         }
 
 
-        return array('form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id);
+        return ['form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id];
     }
     }
 
 
     protected function _getFormEdit($iCmtId, $aDp = [])
     protected function _getFormEdit($iCmtId, $aDp = [])