diff --git a/modules/boonex/spaces/classes/BxSpacesModule.php b/modules/boonex/spaces/classes/BxSpacesModule.php index 1b144c26bc..fb5f97678c 100644 --- a/modules/boonex/spaces/classes/BxSpacesModule.php +++ b/modules/boonex/spaces/classes/BxSpacesModule.php @@ -36,10 +36,24 @@ public function serviceEntityDelete ($iContentId = 0) $iContentId = $this->_getContent($iContentId, false); if($iContentId === false) return false; + $iCount = $this->_oDb->getCountEntriesByParent($iContentId); - if ($iCount > 0) - return MsgBox(_t('_bx_spaces_err_delete_child_presend')); - return $this->_serviceEntityForm ('deleteDataForm', $iContentId); + if($iCount > 0 && ($sMsg = '_bx_spaces_err_delete_child_presend')) + return !$this->_bIsApi ? MsgBox(_t($sMsg)) : [bx_api_get_msg($sMsg)]; + + $mixedResult = $this->_serviceEntityForm ('deleteDataForm', $iContentId); + if(!$this->_bIsApi) + return $mixedResult; + + $aResult = []; + if(is_a($mixedResult, 'BxTemplFormView')) + $aResult = bx_api_get_block('form', $mixedResult->getCodeAPI(), ['ext' => ['name' => $this->getName(), 'request' => ['url' => '/api.php?r=' . $this->_aModule['name'] . '/entity_delete¶ms[]=' . $iContentId . '¶ms[]=' . $mixedResult->aParams['display'], 'immutable' => true]]]); + else + $aResult = $mixedResult; + + return [ + $aResult + ]; } public function serviceEntityParent ($iContentId = 0, $aParams = [])