roman.lesnikov@gmail.com 3 лет назад
Родитель
Сommit
78e5536103

+ 9 - 3
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -3458,11 +3458,17 @@ class BxBaseModGeneralModule extends BxDolModule
             return false;
         
         if (bx_is_api()){
-            $aForm = $oCmts->getFormPost(0)->getCodeAPI();
-          
+            $aForm = $oCmts->getFormPost(0);
+            if (is_array($aForm)){
+                $aForm['id'] = 2;
+            }
+            else
+                $aData = ['id' => 2, 'type' => 'form', 'data' => $aForm->getCodeAPI(), 'request' => ['url' => '/api.php?r=' . $this->_aModule['name'] . '/entity_comments', 'immutable' => true]];
+            
+            
             return [
                 ['id' => 1, 'type' => 'browse', 'data' => $oCmts->getCommentsBlockAPI([], ['in_designbox' => false, 'show_empty' => false])],
-                ['id' => 2, 'type' => 'form', 'data' => $aForm, 'request' => ['url' => '/api.php?r=' . $this->_aModule['name'] . '/entity_comments', 'immutable' => true]]
+                $aForm 
             ];
         }
         return $oCmts->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => false));

+ 3 - 3
template/scripts/BxBaseCmts.php

@@ -1135,11 +1135,11 @@ class BxBaseCmts extends BxDolCmts
             else
                 $sMsg = $this->msgErrPostAllowed();
 
-            return bx_is_api() ? [['id' => 1, 'type' => 'msg', 'data' => $sMsg]] : ['msg' => $sMsg];
+            return bx_is_api() ? ['id' => 1, 'type' => 'msg', 'data' => $sMsg] : ['msg' => $sMsg];
         }
 
         if($bCmtParentId && !$this->isReplyAllowed($iCmtParentId))
-            return bx_is_api() ? [['id' => 1, 'type' => 'msg', 'data' => $sMsg]] : ['msg' => $this->msgErrReplyAllowed()];
+            return bx_is_api() ? ['id' => 1, 'type' => 'msg', 'data' => $sMsg] : ['msg' => $this->msgErrReplyAllowed()];
 
         $bDynamic = isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'];
         $bQuote = isset($aDp['quote']) && (bool)$aDp['quote'];
@@ -1227,7 +1227,7 @@ class BxBaseCmts extends BxDolCmts
                     }
                 }
             }
-            return bx_is_api() ? [['id' => 1, 'type' => 'msg', 'data' => _t('_cmt_err_cannot_perform_action')]] : ['msg' => _t('_cmt_err_cannot_perform_action')];
+            return bx_is_api() ? ['id' => 1, 'type' => 'msg', 'data' => _t('_cmt_err_cannot_perform_action')] : ['msg' => _t('_cmt_err_cannot_perform_action')];
         }
         return bx_is_api() ? $oForm : ['form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id];
     }