BxFilesModule.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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. if (isset($aData['type']) && $aData['type'] == 'folder') {
  136. return [
  137. 'id' => $aData[$CNF['FIELD_ID']],
  138. 'profile_id' => $aData[$CNF['FIELD_AUTHOR']],
  139. 'remote_id' => 0,
  140. 'path' => '',
  141. 'file_name' => $aData[$CNF['FIELD_TITLE']],
  142. 'mime_type' => '',
  143. 'ext' => '',
  144. 'size' => 0,
  145. 'added' => $aData[$CNF['FIELD_ADDED']],
  146. 'modified' => 0,
  147. 'private' => false,
  148. 'is_image' => false,
  149. ];
  150. }
  151. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  152. if (!$oStorage)
  153. return false;
  154. if (isset($aData[$CNF['FIELD_FILE_ID']]) && $aData[$CNF['FIELD_FILE_ID']])
  155. return $this->_addFileFields($oStorage->getFile($aData[$CNF['FIELD_FILE_ID']]));
  156. $aGhostFiles = $oStorage->getGhosts ($aData[$CNF['FIELD_AUTHOR']], $aData[$CNF['FIELD_ID']]);
  157. if (!$aGhostFiles)
  158. return false;
  159. return $this->_addFileFields(array_pop($aGhostFiles));
  160. }
  161. protected function _addFileFields($aFile)
  162. {
  163. if (is_array($aFile))
  164. $aFile['is_image'] = in_array($aFile['ext'], array('jpg', 'jpeg', 'png', 'gif', /* when ImageMagick is used - 'tif', 'tiff', 'bmp', 'ico', 'psd' */));
  165. return $aFile;
  166. }
  167. public function serviceEntityFilePreview($iContentId = 0)
  168. {
  169. return $this->_serviceTemplateFunc ('entryFilePreview', $iContentId);
  170. }
  171. public function serviceProcessFilesData($iNumberOfFilesToProcessAtOnce = 3)
  172. {
  173. $CNF = $this->_oConfig->CNF;
  174. if (!defined('BX_SYSTEM_JAVA') || !constant('BX_SYSTEM_JAVA'))
  175. return;
  176. $a = $this->_oDb->getNotProcessedFiles($iNumberOfFilesToProcessAtOnce);
  177. if (!$a)
  178. return;
  179. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  180. if (!$oStorage)
  181. return false;
  182. foreach ($a as $aContentInfo) {
  183. $aFile = $this->getContentFile($aContentInfo);
  184. if (!$aFile) {
  185. $this->_oDb->updateFileData ($aContentInfo[$CNF['FIELD_ID']], '');
  186. continue;
  187. }
  188. $sFileUrl = $oStorage->getFileUrlById($aFile['id']);
  189. $sFilePath = BX_DIRECTORY_PATH_TMP . $aFile['remote_id'] . '.' . $aFile['ext'];
  190. @file_put_contents($sFilePath, file_get_contents($sFileUrl));
  191. if (!file_exists($sFilePath)) {
  192. $this->_oDb->updateFileData ($aContentInfo[$CNF['FIELD_ID']], '');
  193. continue;
  194. }
  195. $sCommand = '"' . constant('BX_SYSTEM_JAVA') . '" -jar "' . $this->_oConfig->getHomePath() . 'data/tika-app.jar" --encoding=UTF-8 --text "' . $sFilePath . '"';
  196. $sData = `$sCommand`;
  197. @unlink($sFilePath);
  198. $this->_oDb->updateFileData ($aContentInfo[$CNF['FIELD_ID']], $sData);
  199. }
  200. }
  201. public function servicePruneDownloadingJobs()
  202. {
  203. $aFiles = $this->_oDb->deleteOldDownloadingJobs();
  204. if ($aFiles) foreach ($aFiles as $sFile) @unlink($sFile);
  205. }
  206. protected function _getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams = array())
  207. {
  208. $aResult = parent::_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams);
  209. $aFile = $this->getContentFile($aContentInfo);
  210. if (!$aFile['is_image']) {
  211. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
  212. $sIcon = $oStorage ? $oStorage->getFontIconNameByFileName($aFile['file_name']) : 'far file';
  213. $aResult['raw'] = $this->_oTemplate->parseHtmlByName('timeline_post.html', array(
  214. 'title' => $aResult['title'],
  215. 'title_attr' => bx_html_attribute($aResult['title']),
  216. 'url' => $aResult['url'],
  217. 'icon' => $sIcon,
  218. ));
  219. $aResult['title'] = '';
  220. }
  221. return $aResult;
  222. }
  223. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  224. {
  225. $aFile = $this->getContentFile($aContentInfo);
  226. if (!$aFile)
  227. return array();
  228. if (!$aFile['is_image'])
  229. return array();
  230. $sPhotoThumb = '';
  231. if ($oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($this->_oConfig->CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
  232. $sPhotoThumb = $oImagesTranscoder->getFileUrl($aFile['id']);
  233. return array(
  234. array('id' => $aFile['id'], 'url' => $sUrl, 'src' => $sPhotoThumb),
  235. );
  236. }
  237. public function actionBookmark($iContentId) {
  238. if (!$this->isLogged()) return;
  239. $aFilesToBookmark = [];
  240. if ($iContentId) $aFilesToBookmark = [$iContentId];
  241. elseif (isset($_POST['bulk'])) $aFilesToBookmark = $_POST['bulk'];
  242. if ($aFilesToBookmark)
  243. foreach ($aFilesToBookmark as $iContentId) {
  244. if ($iContentId <= 0) continue;
  245. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  246. if (!$aData) continue;
  247. $this->_oDb->bookmarkFile((int)$iContentId, bx_get_logged_profile_id());
  248. }
  249. }
  250. public function actionEntryPreview($iContentId) {
  251. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  252. $sJsCss = '';
  253. $sPreviewCode = $this->_serviceTemplateFunc ('entryFilePreview', $iContentId);
  254. // various init scripts could be there, which fail to work properly
  255. // because of a fact that it is inside a popup which is at the moment is hidden
  256. // so we need a way to postpone that initialization
  257. $aScripts = [];
  258. $sPreviewCode = preg_replace_callback('/<script>(.*)<\/script>/s', function($aMatch) use (&$aScripts) {
  259. $aScripts[] = ['code' => $aMatch[1]];
  260. return '';
  261. }, $sPreviewCode);
  262. // if there is a script then most likely it is a text + codemirror initialization, so include it here.
  263. if ($aScripts) {
  264. $sJsCss .= $this->_oTemplate->addJs('codemirror/codemirror-ext.min.js', true);
  265. $sJsCss .= $this->_oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css', true);
  266. }
  267. $sJsCss .= $this->_oTemplate->addCss('file_handler.css', true);
  268. $sPopupCode = $this->_oTemplate->parseHtmlByName('entry-popup.html', [
  269. 'content' => $sPreviewCode,
  270. 'bx_repeat:init_scripts' => $aScripts,
  271. ]);
  272. echoJson([
  273. 'popup' => [
  274. 'html' => PopupBox('bx-files-popup', bx_process_output($aData['title']), $sJsCss.$sPopupCode),
  275. 'options' => [
  276. 'onShow' => 'bx_files_popup_init()',
  277. ],
  278. ],
  279. ]);
  280. }
  281. public function actionEntryInfo($iContentId) {
  282. $aData = $this->_oDb->getContentInfoById((int)$iContentId);
  283. echoJson([
  284. 'popup' => [
  285. 'html' => PopupBox('bx-files-popup', bx_process_output($aData['title']), $this->_oTemplate->entryInfoPopup($aData)),
  286. ],
  287. ]);
  288. }
  289. public function actionEntryEditTitle($iContentId) {
  290. $iContentId = intval($iContentId);
  291. $aData = $this->_oDb->getContentInfoById($iContentId);
  292. $CNF = &$this->_oConfig->CNF;
  293. if (!$aData) {
  294. echoJson(['message' => _t('_bx_files_txt_error')]);
  295. exit;
  296. }
  297. if ($aData[$CNF['FIELD_AUTHOR']] != bx_get_logged_profile_id()) {
  298. echoJson(['message' => _t('_bx_files_txt_permission_denied')]);
  299. exit;
  300. }
  301. if (isset($_POST['title'])) {
  302. if ($sNewTitle = bx_get('title')) {
  303. $this->_oDb->updateEntryTitle($iContentId, $sNewTitle);
  304. $aData = $this->_oDb->getContentInfoById($iContentId);
  305. echo bx_process_output($aData[$CNF['FIELD_TITLE']]);
  306. }
  307. exit;
  308. }
  309. $sActionUrl = BX_DOL_URL_ROOT.$this->_oConfig->getBaseUri();
  310. echoJson([
  311. 'eval' => "bx_prompt('"._t('_bx_files_form_entry_input_title')."', '".bx_js_string($aData[$CNF['FIELD_TITLE']])."', function(val) {
  312. $.post('{$sActionUrl}entry_edit_title/{$iContentId}', {title: val.getValue()}, function(sTitle) {
  313. if (sTitle)
  314. $('.bx-file-entry[file_id=".$aData[$CNF['FIELD_ID']]."] .bx-files-filename a').html(sTitle);
  315. });
  316. })",
  317. ]);
  318. }
  319. public function actionEntryDelete($iContentId) {
  320. $aFilesToDelete = [];
  321. if ($iContentId) $aFilesToDelete = [$iContentId];
  322. elseif (isset($_POST['bulk'])) $aFilesToDelete = $_POST['bulk'];
  323. if ($aFilesToDelete)
  324. foreach ($aFilesToDelete as $iContentId) {
  325. $iContentId = intval($iContentId);
  326. if ($iContentId <= 0) continue;
  327. $aData = $this->_oDb->getContentInfoById($iContentId);
  328. $CNF = &$this->_oConfig->CNF;
  329. if (!$aData) {
  330. echoJson(['message' => _t('_bx_files_txt_error')]);
  331. exit;
  332. }
  333. 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']]))) {
  334. echoJson(['message' => _t('_bx_files_txt_permission_denied')]);
  335. exit;
  336. }
  337. $this->serviceDeleteEntity($iContentId);
  338. }
  339. if (!isset($_POST['bulk'])) {
  340. echoJson([
  341. 'eval' => "
  342. $('.bx-file-entry[file_id={$iContentId}]').fadeOut();
  343. $(window).trigger('files_browser.update');
  344. ",
  345. ]);
  346. } else {
  347. echoJson([]);
  348. }
  349. }
  350. public function actionClearGhosts() {
  351. if (!isLogged()) die;
  352. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
  353. if ($oStorage) {
  354. $aFiles = $oStorage->getGhosts(bx_get_logged_profile_id(), 0);
  355. if ($aFiles) foreach ($aFiles as $aFile) {
  356. $oStorage->deleteFile($aFile['id']);
  357. }
  358. }
  359. }
  360. public function actionUploadCompleted() {
  361. $iContext = intval(bx_get('context'));
  362. $iFolder = intval(bx_get('folder'));
  363. if (!isLogged()) {
  364. echoJson(['message' => _t('_Access denied')]);
  365. exit;
  366. }
  367. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContext)) {
  368. echoJson(['message' => _t('_Access denied')]);
  369. exit;
  370. }
  371. $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->CNF['OBJECT_STORAGE']);
  372. if ($oStorage) {
  373. $iAuthorProfile = bx_get_logged_profile_id();
  374. $aFiles = $oStorage->getGhosts($iAuthorProfile, 0);
  375. if ($aFiles) {
  376. $aFilesIDs = [];
  377. foreach($aFiles as $aFile) {
  378. $aFilesIDs[] = $aFile['id'];
  379. bx_set('title-'.$aFile['id'], $aFile['file_name'], 'post');
  380. }
  381. bx_set('attachments', $aFilesIDs, 'post');
  382. $oForm = BxDolForm::getObjectInstance($this->_oConfig->CNF['OBJECT_FORM_ENTRY_UPLOAD'], $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_UPLOAD']);
  383. $oForm->aInputs['profile_id']['value'] = $iAuthorProfile;
  384. $oForm->aInputs['allow_view_to']['value'] = $iContext == $iAuthorProfile ? 3 : -$iContext;
  385. $aFiles = $oForm->insert();
  386. if ($iFolder != 0 && !empty($aFiles))
  387. $this->_oDb->moveFilesToFolder($aFiles, $iFolder);
  388. }
  389. }
  390. }
  391. public function actionCreateFolder() {
  392. $iContext = intval(bx_get('context'));
  393. $iFolder = intval(bx_get('current_folder'));
  394. $sName = trim(bx_get('name'));
  395. if (!isLogged()) {
  396. echoJson(['message' => _t('_Access denied')]);
  397. exit;
  398. }
  399. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContext)) {
  400. echoJson(['message' => _t('_Access denied')]);
  401. exit;
  402. }
  403. if (!empty($sName)) {
  404. $iAuthor = bx_get_logged_profile_id();
  405. //in case it is posted to context make the context profile as an author of an entry
  406. $this->_oDb->createFolder($iFolder, $iAuthor == $iContext ? $iAuthor : $iContext, $iAuthor == $iContext ? BX_DOL_PG_ALL : -$iContext, $sName);
  407. }
  408. echoJson([]);
  409. exit;
  410. }
  411. public function actionMoveFiles() {
  412. $iContentId = intval(bx_get('file'));
  413. $aFilesToMove = [];
  414. if ($iContentId) $aFilesToMove = [$iContentId];
  415. elseif (isset($_POST['bulk'])) $aFilesToMove = $_POST['bulk'];
  416. $iContentId = reset($aFilesToMove);
  417. $aData = $this->_oDb->getContentInfoById($iContentId);
  418. if (!$aData) {
  419. echoJson(['message' => _t('_bx_files_txt_error')]);
  420. exit;
  421. }
  422. $CNF = &$this->_oConfig->CNF;
  423. $iContext = $aData[$CNF['FIELD_ALLOW_VIEW_TO']] < 0 ? -$aData[$CNF['FIELD_ALLOW_VIEW_TO']] : $aData[$CNF['FIELD_AUTHOR']];
  424. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContext)) {
  425. echoJson(['message' => _t('_Access denied')]);
  426. exit;
  427. }
  428. if (isset($_POST['move_to'])) {
  429. $iMoveTo = intval(bx_get('move_to'));
  430. if ($iMoveTo) {
  431. $aDataMoveTo = $this->_oDb->getContentInfoById($iMoveTo);
  432. if (!$aDataMoveTo) {
  433. echoJson(['message' => _t('_bx_files_txt_error')]);
  434. exit;
  435. }
  436. $iContextMoveTo = $aDataMoveTo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0 ? -$aDataMoveTo[$CNF['FIELD_ALLOW_VIEW_TO']] : $aDataMoveTo[$CNF['FIELD_AUTHOR']];
  437. if ($this->checkAllowedAdd() != CHECK_ACTION_RESULT_ALLOWED || !$this->serviceIsAllowedAddContentToProfile($iContextMoveTo)) {
  438. echoJson(['message' => _t('_Access denied')]);
  439. exit;
  440. }
  441. }
  442. $this->_oDb->moveFilesToFolder($aFilesToMove, $iMoveTo);
  443. echoJson([
  444. 'eval' => "
  445. $(window).trigger('files_browser.update');
  446. ",
  447. ]);
  448. exit;
  449. }
  450. $aFolders = $this->_oDb->getFoldersInContext($iContext);
  451. if (!$aFolders) {
  452. echoJson(['message' => _t('_bx_files_txt_move_to_nowhere')]);
  453. exit;
  454. }
  455. echoJson([
  456. 'popup' => [
  457. 'html' => PopupBox('bx-files-popup', _t('_bx_files_txt_move_to'), $this->_oTemplate->getJsTree($aFilesToMove, $aFolders)),
  458. 'options' => [],
  459. ],
  460. ]);
  461. }
  462. public function serviceDeleteEntitiesByAuthor ($iProfileId) {
  463. $this->_oDb->deleteProfileBookmarks($iProfileId);
  464. return parent::serviceDeleteEntitiesByAuthor ($iProfileId);
  465. }
  466. public function serviceDeleteEntity ($iContentId, $sFuncDelete = 'deleteData') {
  467. $aData = $this->_oDb->getContentInfoById($iContentId);
  468. if ($aData['type'] == 'folder') {
  469. $aNestedFiles = $this->_oDb->getFolderFiles($aData[$this->_oConfig->CNF['FIELD_ID']]);
  470. if ($aNestedFiles)
  471. foreach ($aNestedFiles as $iFile) {
  472. $this->serviceDeleteEntity($iFile);
  473. }
  474. }
  475. parent::serviceDeleteEntity($iContentId, $sFuncDelete);
  476. }
  477. }
  478. /** @} */