Skip to content

Commit

Permalink
#4148 - Build-in API support (cmts)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlesnikov committed Jan 23, 2023
1 parent 06b52c0 commit 78e5536
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions modules/base/general/classes/BxBaseModGeneralModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3458,11 +3458,17 @@ protected function _entityComments ($sObject, $iId = 0)
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));
Expand Down
6 changes: 3 additions & 3 deletions template/scripts/BxBaseCmts.php
Original file line number Diff line number Diff line change
Expand Up @@ -1135,11 +1135,11 @@ protected function _getFormPost($iCmtParentId = 0, $aDp = [])
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'];
Expand Down Expand Up @@ -1227,7 +1227,7 @@ protected function _getFormPost($iCmtParentId = 0, $aDp = [])
}
}
}
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];
}
Expand Down

0 comments on commit 78e5536

Please sign in to comment.