BxFilesModule.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Files Files
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Files module
  13. */
  14. class BxFilesModule extends BxBaseModTextModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. public function serviceIsAllowedAddContentToProfile($iGroupProfileId)
  21. {
  22. if (!$iGroupProfileId || !($oProfile = BxDolProfile::getInstance((int)$iGroupProfileId)))
  23. return false;
  24. if ($iGroupProfileId == bx_get_logged_profile_id())
  25. return true;
  26. $sProfileModule = $oProfile->getModule();
  27. $aContentInfo = BxDolService::call($sProfileModule, 'get_content_info_by_id', array($oProfile->getContentId()));
  28. if (BxDolService::call($sProfileModule, 'is_group_profile') && (BxDolService::call($sProfileModule, 'is_fan', array($iGroupProfileId)) || bx_get_logged_profile_id() == $aContentInfo['author']))
  29. return true;
  30. return false;
  31. }
  32. public function serviceMyEntriesActions ($iProfileId = 0)
  33. {
  34. if (!$iProfileId)
  35. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  36. if (!$this->serviceIsAllowedAddContentToProfile($iProfileId))
  37. return false;
  38. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']);
  39. return $oMenu ? $oMenu->getCode() : false;
  40. }
  41. public function checkAllowedSetThumb ($iContentId = 0)
  42. {
  43. return _t('_sys_txt_access_denied');
  44. }
  45. public function actionDownload($sToken, $iContentId, $sBulk = '')
  46. {
  47. $CNF = $this->_oConfig->CNF;
  48. $aFilesToDownload = [$iContentId];
  49. if (!empty($sBulk)) {
  50. $aFilesToDownload = json_decode($sBulk);
  51. }
  52. if (!is_array($aFilesToDownload)) {
  53. $this->_oTemplate->displayPageNotFound();
  54. return;
  55. }
  56. $iContentId = reset($aFilesToDownload);
  57. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  58. if (!$aData) {
  59. $this->_oTemplate->displayPageNotFound();
  60. return;
  61. }
  62. if (CHECK_ACTION_RESULT_ALLOWED !== $this->checkAllowedView($aData)) {
  63. $this->_oTemplate->displayAccessDenied();
  64. return;
  65. }
  66. if ($aData['type'] == 'folder' || $aFilesToDownload && count($aFilesToDownload) > 1) {
  67. bx_import('BulkDownloader', $this->_aModule);
  68. $oDownloader = new BxFilesBulkDownloader($this);
  69. $aResult = $oDownloader->createDownloadingJob($aFilesToDownload, $aData[$CNF['FIELD_TITLE']]);
  70. switch ($aResult['status']) {
  71. case BX_FILES_DOWNLOADER_STATUS_TOO_LARGE:
  72. $this->_oTemplate->displayMsg(_t('_bx_files_txt_max_size_reached', _t_format_size(intval(getParam('bx_files_max_bulk_download_size')) * 1024 * 1024)));
  73. break;
  74. case BX_FILES_DOWNLOADER_STATUS_DOWNLOADING:
  75. $this->_oTemplate->addJsTranslation('_bx_files_txt_status_downloading_ready_msg');
  76. $this->_oTemplate->displayMsg(['title' => _t('_bx_files_txt_status_downloading'), 'content' => $this->_oTemplate->parseHtmlByName('bulk_downloader_process.html', [
  77. 'timeout' => BX_FILES_DOWNLOADER_TIMEOUT_REQUESTS,
  78. 'action_url' => BX_DOL_URL_ROOT.$this->_oConfig->getBaseUri().'process_download/'.$aResult['job'],
  79. ])]);
  80. break;
  81. case BX_FILES_DOWNLOADER_STATUS_READY:
  82. bx_smart_readfile($aResult['file'], $aResult['filename'], 'application/zip');
  83. break;
  84. case BX_FILES_DOWNLOADER_STATUS_EMPTY:
  85. default:
  86. $this->_oTemplate->displayPageNotFound();
  87. break;
  88. }
  89. exit;
  90. }
  91. $aFile = $this->getContentFile($aData);
  92. if (!$aFile) {
  93. $this->_oTemplate->displayPageNotFound();
  94. return;
  95. }
  96. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  97. if (!$oStorage) {
  98. $this->_oTemplate->displayErrorOccured();
  99. return;
  100. }
  101. if (!$oStorage->download($aFile['remote_id'], $sToken)) {
  102. $this->_oTemplate->displayErrorOccured();
  103. return;
  104. }
  105. exit;
  106. }
  107. public function actionProcessDownload($iDownloadingJobId) {
  108. if (!$iDownloadingJobId) die;
  109. $aJob = $this->_oDb->getDownloadingJob($iDownloadingJobId);
  110. if (!$aJob || $aJob['owner'] != bx_get_logged_profile_id()) die;
  111. if ($aJob['result']) {
  112. bx_smart_readfile($aJob['result'], $aJob['name'], 'application/zip');
  113. exit;
  114. }
  115. bx_import('BulkDownloader', $this->_aModule);
  116. $oDownloader = new BxFilesBulkDownloader($this);
  117. $mRes = $oDownloader->processDownloading($aJob['files']);
  118. if ($mRes === BX_FILES_DOWNLOADER_STATUS_DOWNLOADING) {
  119. $this->_oDb->updateDownloadingJob($iDownloadingJobId, $aJob['files'], '');
  120. echoJson([
  121. 'status' => 'downloading',
  122. ]);
  123. } else {
  124. $this->_oDb->updateDownloadingJob($iDownloadingJobId, $aJob['files'], $mRes);
  125. echoJson([
  126. 'status' => 'ready',
  127. ]);
  128. }
  129. }
  130. public function getContentFile($aData)
  131. {
  132. $CNF = $this->_oConfig->CNF;
  133. if (!isset($aData[$CNF['FIELD_AUTHOR']]) || !isset($aData[$CNF['FIELD_ID']]))
  134. return false;
  135. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  136. if (!$oStorage)
  137. return false;
  138. if (isset($aData[$CNF['FIELD_FILE_ID']]) && $aData[$CNF['FIELD_FILE_ID']])
  139. return $this->_addFileFields($oStorage->getFile($aData[$CNF['FIELD_FILE_ID']]));
  140. $aGhostFiles = $oStorage->getGhosts ($aData[$CNF['FIELD_AUTHOR']], $aData[$CNF['FIELD_ID']]);
  141. if (!$aGhostFiles)
  142. return false;
  143. return $this->_addFileFields(array_pop($aGhostFiles));
  144. }
  145. protected function _addFileFields($aFile)
  146. {
  147. if (is_array($aFile))
  148. $aFile['is_image'] = in_array($aFile['ext'], array('jpg', 'jpeg', 'png', 'gif', /* when ImageMagick is used - 'tif', 'tiff', 'bmp', 'ico', 'psd' */));
  149. return $aFile;
  150. }
  151. public function serviceEntityFilePreview($iContentId = 0)
  152. {
  153. return $this->_serviceTemplateFunc ('entryFilePreview', $iContentId);
  154. }
  155. public function serviceProcessFilesData($iNumberOfFilesToProcessAtOnce = 3)
  156. {
  157. $CNF = $this->_oConfig->CNF;
  158. if (!defined('BX_SYSTEM_JAVA') || !constant('BX_SYSTEM_JAVA'))
  159. return;
  160. $a = $this->_oDb->getNotProcessedFiles($iNumberOfFilesToProcessAtOnce);
  161. if (!$a)
  162. return;
  163. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  164. if (!$oStorage)
  165. return false;
  166. foreach ($a as $aContentInfo) {
  167. $aFile = $this->getContentFile($aContentInfo);
  168. if (!$aFile) {
  169. $this->_oDb->updateFileData ($aContentInfo[$CNF['FIELD_ID']], '');
  170. continue;
  171. }
  172. $sFileUrl = $oStorage->getFileUrlById($aFile['id']);
  173. $sFilePath = BX_DIRECTORY_PATH_TMP . $aFile['remote_id'] . '.' . $aFile['ext'];
  174. @file_put_contents($sFilePath, file_get_contents($sFileUrl));
  175. if (!file_exists($sFilePath)) {
  176. $this->_oDb->updateFileData ($aContentInfo[$CNF['FIELD_ID']], '');
  177. continue;
  178. }
  179. $sCommand = '"' . constant('BX_SYSTEM_JAVA') . '" -jar "' . $this->_oConfig->getHomePath() . 'data/tika-app.jar" --encoding=UTF-8 --text "' . $sFilePath . '"';
  180. $sData = `$sCommand`;
  181. @unlink($sFilePath);
  182. $this->_oDb->updateFileData ($aContentInfo[$CNF['FIELD_ID']], $sData);
  183. }
  184. }
  185. public function servicePruneDownloadingJobs()
  186. {
  187. $aFiles = $this->_oDb->deleteOldDownloadingJobs();
  188. if ($aFiles) foreach ($aFiles as $sFile) @unlink($sFile);
  189. }
  190. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  191. {
  192. $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
  193. $aFile = $this->getContentFile($aContentInfo);
  194. if (!$aFile['is_image']) {
  195. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
  196. $sIcon = $oStorage ? $oStorage->getFontIconNameByFileName($aFile['file_name']) : 'far file';
  197. $aResult['raw'] = $this->_oTemplate->parseHtmlByName('timeline_post.html', array(
  198. 'title' => $aResult['title'],
  199. 'title_attr' => bx_html_attribute($aResult['title']),
  200. 'url' => $aResult['url'],
  201. 'icon' => $sIcon,
  202. ));
  203. $aResult['title'] = '';
  204. }
  205. return $aResult;
  206. }
  207. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  208. {
  209. $aFile = $this->getContentFile($aContentInfo);
  210. if (!$aFile)
  211. return array();
  212. if (!$aFile['is_image'])
  213. return array();
  214. $sPhotoThumb = '';
  215. if ($oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($this->_oConfig->CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
  216. $sPhotoThumb = $oImagesTranscoder->getFileUrl($aFile['id']);
  217. return array(
  218. array('id' => $aFile['id'], 'url' => $sUrl, 'src' => $sPhotoThumb),
  219. );
  220. }
  221. public function actionBookmark($iContentId) {
  222. if (!$this->isLogged()) return;
  223. $aFilesToBookmark = [];
  224. if ($iContentId) $aFilesToBookmark = [$iContentId];
  225. elseif (isset($_POST['bulk'])) $aFilesToBookmark = $_POST['bulk'];
  226. if ($aFilesToBookmark)
  227. foreach ($aFilesToBookmark as $iContentId) {
  228. if ($iContentId <= 0) continue;
  229. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  230. if (!$aData) continue;
  231. $this->_oDb->bookmarkFile((int)$iContentId, bx_get_logged_profile_id());
  232. }
  233. }
  234. public function actionEntryPreview($iContentId) {
  235. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  236. $sJsCss = '';
  237. $sPreviewCode = $this->_serviceTemplateFunc ('entryFilePreview', $iContentId);
  238. // various init scripts could be there, which fail to work properly
  239. // because of a fact that it is inside a popup which is at the moment is hidden
  240. // so we need a way to postpone that initialization
  241. $aScripts = [];
  242. $sPreviewCode = preg_replace_callback('/<script>(.*)<\/script>/s', function($aMatch) use (&$aScripts) {
  243. $aScripts[] = ['code' => $aMatch[1]];
  244. return '';
  245. }, $sPreviewCode);
  246. // if there is a script then most likely it is a text + codemirror initialization, so include it here.
  247. if ($aScripts) {
  248. $sJsCss .= $this->_oTemplate->addJs('codemirror/codemirror-ext.min.js', true);
  249. $sJsCss .= $this->_oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css', true);
  250. }
  251. $sJsCss .= $this->_oTemplate->addCss('file_handler.css', true);
  252. $sPopupCode = $this->_oTemplate->parseHtmlByName('entry-popup.html', [
  253. 'content' => $sPreviewCode,
  254. 'bx_repeat:init_scripts' => $aScripts,
  255. ]);
  256. echoJson([
  257. 'popup' => [
  258. 'html' => PopupBox('bx-files-popup', bx_process_output($aData['title']), $sJsCss.$sPopupCode),
  259. 'options' => [
  260. 'onShow' => 'bx_files_popup_init()',
  261. ],
  262. ],
  263. ]);
  264. }
  265. public function actionEntryInfo($iContentId) {
  266. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  267. echoJson([
  268. 'popup' => [
  269. 'html' => PopupBox('bx-files-popup', bx_process_output($aData['title']), $this->_oTemplate->entryInfoPopup($aData)),
  270. ],
  271. ]);
  272. }
  273. public function actionEntryEditTitle($iContentId) {
  274. $iContentId = intval($iContentId);
  275. $aData = $this->_oDb->getContentInfoById($iContentId);
  276. $CNF = &$this->_oConfig->CNF;
  277. if (!$aData) {
  278. echoJson(['message' => _t('_bx_files_txt_error')]);
  279. exit;
  280. }
  281. if ($aData[$CNF['FIELD_AUTHOR']] != bx_get_logged_profile_id()) {
  282. echoJson(['message' => _t('_bx_files_txt_permission_denied')]);
  283. exit;
  284. }
  285. if (isset($_POST['title'])) {
  286. if ($sNewTitle = bx_get('title')) {
  287. $this->_oDb->updateEntryTitle($iContentId, $sNewTitle);
  288. $aData = $this->_oDb->getContentInfoById($iContentId);
  289. echo bx_process_output($aData[$CNF['FIELD_TITLE']]);
  290. }
  291. exit;
  292. }
  293. $sActionUrl = BX_DOL_URL_ROOT.$this->_oConfig->getBaseUri();
  294. echoJson([
  295. 'eval' => "bx_prompt('"._t('_bx_files_form_entry_input_title')."', '".bx_js_string($aData[$CNF['FIELD_TITLE']])."', function(val) {
  296. $.post('{$sActionUrl}entry_edit_title/{$iContentId}', {title: val.getValue()}, function(sTitle) {
  297. if (sTitle)
  298. $('.bx-file-entry[file_id=".$aData[$CNF['FIELD_ID']]."] .bx-files-filename a').html(sTitle);
  299. });
  300. })",
  301. ]);
  302. }
  303. public function actionEntryDelete($iContentId) {
  304. $aFilesToDelete = [];
  305. if ($iContentId) $aFilesToDelete = [$iContentId];
  306. elseif (isset($_POST['bulk'])) $aFilesToDelete = $_POST['bulk'];
  307. if ($aFilesToDelete)
  308. foreach ($aFilesToDelete as $iContentId) {
  309. $iContentId = intval($iContentId);
  310. if ($iContentId <= 0) continue;
  311. $aData = $this->_oDb->getContentInfoById($iContentId);
  312. $CNF = &$this->_oConfig->CNF;
  313. if (!$aData) {
  314. echoJson(['message' => _t('_bx_files_txt_error')]);
  315. exit;
  316. }
  317. if ($aData[$CNF['FIELD_AUTHOR']] != bx_get_logged_profile_id() && !($aData[$CNF['FIELD_ALLOW_VIEW_TO']] < 0 && $this->serviceIsAllowedAddContentToProfile(-$aData[$CNF['FIELD_ALLOW_VIEW_TO']]))) {
  318. echoJson(['message' => _t('_bx_files_txt_permission_denied')]);
  319. exit;
  320. }
  321. $this->serviceDeleteEntity($iContentId);
  322. }
  323. if (!isset($_POST['bulk'])) {
  324. echoJson([
  325. 'eval' => "
  326. $('.bx-file-entry[file_id={$iContentId}]').fadeOut();
  327. $(window).trigger('files_browser.update');
  328. ",
  329. ]);
  330. } else {
  331. echoJson([]);
  332. }
  333. }
  334. public function actionClearGhosts() {
  335. if (!isLogged()) die;
  336. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
  337. if ($oStorage) {
  338. $aFiles = $oStorage->getGhosts(bx_get_logged_profile_id(), 0);
  339. if ($aFiles) foreach ($aFiles as $aFile) {
  340. $oStorage->deleteFile($aFile['id']);
  341. }
  342. }
  343. }
  344. public function actionUploadCompleted() {
  345. $iContext = intval(bx_get('context'));
  346. $iFolder = intval(bx_get('folder'));
  347. if (!isLogged()) {
  348. echoJson(['message' => _t('_Access denied')]);
  349. exit;
  350. }
  351. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContext)) {
  352. echoJson(['message' => _t('_Access denied')]);
  353. exit;
  354. }
  355. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
  356. if ($oStorage) {
  357. $iAuthorProfile = bx_get_logged_profile_id();
  358. $aFiles = $oStorage->getGhosts($iAuthorProfile, 0);
  359. if ($aFiles) {
  360. $aFilesIDs = [];
  361. foreach($aFiles as $aFile) {
  362. $aFilesIDs[] = $aFile['id'];
  363. bx_set('title-'.$aFile['id'], $aFile['file_name'], 'post');
  364. }
  365. bx_set('attachments', $aFilesIDs, 'post');
  366. $oForm = BxDolForm::getObjectInstance($this->_oConfig->CNF['OBJECT_FORM_ENTRY_UPLOAD'], $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_UPLOAD']);
  367. $oForm->aInputs['profile_id']['value'] = $iAuthorProfile;
  368. $oForm->aInputs['allow_view_to']['value'] = $iContext == $iAuthorProfile ? 3 : -$iContext;
  369. $aFiles = $oForm->insert();
  370. if ($iFolder != 0 && !empty($aFiles))
  371. $this->_oDb->moveFilesToFolder($aFiles, $iFolder);
  372. }
  373. }
  374. }
  375. public function actionCreateFolder() {
  376. $iContext = intval(bx_get('context'));
  377. $iFolder = intval(bx_get('current_folder'));
  378. $sName = trim(bx_get('name'));
  379. if (!isLogged()) {
  380. echoJson(['message' => _t('_Access denied')]);
  381. exit;
  382. }
  383. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContext)) {
  384. echoJson(['message' => _t('_Access denied')]);
  385. exit;
  386. }
  387. if (!empty($sName)) {
  388. $iAuthor = bx_get_logged_profile_id();
  389. //in case it is posted to context make the context profile as an author of an entry
  390. $this->_oDb->createFolder($iFolder, $iAuthor == $iContext ? $iAuthor : $iContext, $iAuthor == $iContext ? BX_DOL_PG_ALL : -$iContext, $sName);
  391. }
  392. echoJson([]);
  393. exit;
  394. }
  395. public function actionMoveFiles() {
  396. $iContentId = intval(bx_get('file'));
  397. $aFilesToMove = [];
  398. if ($iContentId) $aFilesToMove = [$iContentId];
  399. elseif (isset($_POST['bulk'])) $aFilesToMove = $_POST['bulk'];
  400. $iContentId = reset($aFilesToMove);
  401. $aData = $this->_oDb->getContentInfoById($iContentId);
  402. if (!$aData) {
  403. echoJson(['message' => _t('_bx_files_txt_error')]);
  404. exit;
  405. }
  406. $CNF = &$this->_oConfig->CNF;
  407. $iContext = $aData[$CNF['FIELD_ALLOW_VIEW_TO']] < 0 ? -$aData[$CNF['FIELD_ALLOW_VIEW_TO']] : $aData[$CNF['FIELD_AUTHOR']];
  408. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContext)) {
  409. echoJson(['message' => _t('_Access denied')]);
  410. exit;
  411. }
  412. if (isset($_POST['move_to'])) {
  413. $iMoveTo = intval(bx_get('move_to'));
  414. if ($iMoveTo) {
  415. $aDataMoveTo = $this->_oDb->getContentInfoById($iMoveTo);
  416. if (!$aDataMoveTo) {
  417. echoJson(['message' => _t('_bx_files_txt_error')]);
  418. exit;
  419. }
  420. $iContextMoveTo = $aDataMoveTo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0 ? -$aDataMoveTo[$CNF['FIELD_ALLOW_VIEW_TO']] : $aDataMoveTo[$CNF['FIELD_AUTHOR']];
  421. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContextMoveTo)) {
  422. echoJson(['message' => _t('_Access denied')]);
  423. exit;
  424. }
  425. }
  426. $this->_oDb->moveFilesToFolder($aFilesToMove, $iMoveTo);
  427. echoJson([
  428. 'eval' => "
  429. $(window).trigger('files_browser.update');
  430. ",
  431. ]);
  432. exit;
  433. }
  434. $aFolders = $this->_oDb->getFoldersInContext($iContext);
  435. if (!$aFolders) {
  436. echoJson(['message' => _t('_bx_files_txt_move_to_nowhere')]);
  437. exit;
  438. }
  439. echoJson([
  440. 'popup' => [
  441. 'html' => PopupBox('bx-files-popup', _t('_bx_files_txt_move_to'), $this->_oTemplate->getJsTree($aFilesToMove, $aFolders)),
  442. 'options' => [],
  443. ],
  444. ]);
  445. }
  446. public function serviceDeleteEntitiesByAuthor ($iProfileId) {
  447. $this->_oDb->deleteProfileBookmarks($iProfileId);
  448. return parent::serviceDeleteEntitiesByAuthor ($iProfileId);
  449. }
  450. public function serviceDeleteEntity ($iContentId, $sFuncDelete = 'deleteData') {
  451. $aData = $this->_oDb->getContentInfoById($iContentId);
  452. if ($aData['type'] == 'folder') {
  453. $aNestedFiles = $this->_oDb->getFolderFiles($aData[$this->_oConfig->CNF['FIELD_ID']]);
  454. if ($aNestedFiles)
  455. foreach ($aNestedFiles as $iFile) {
  456. $this->serviceDeleteEntity($iFile);
  457. }
  458. }
  459. parent::serviceDeleteEntity($iContentId, $sFuncDelete);
  460. }
  461. }
  462. /** @} */