recycle.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../inc/global.inc.php';
  4. api_protect_admin_script();
  5. if (!api_get_configuration_value('document_manage_deleted_files')) {
  6. api_not_allowed(true);
  7. }
  8. $courseInfo = api_get_course_info();
  9. $sessionId = api_get_session_id();
  10. $files = DocumentManager::getDeletedDocuments($courseInfo, $sessionId);
  11. $actions = Display::url(
  12. get_lang('DownloadAll'),
  13. api_get_self().'?'.api_get_cidreq().'&action=download_all',
  14. ['class' => 'btn btn-default']
  15. );
  16. $actions .= Display::url(
  17. get_lang('DeleteAll'),
  18. api_get_self().'?'.api_get_cidreq().'&action=delete_all',
  19. ['class' => 'btn btn-danger']
  20. );
  21. $action = isset($_GET['action']) ? $_GET['action'] : '';
  22. $id = isset($_GET['id']) ? intval($_GET['id']) : '';
  23. $currentUrl = api_get_self().'?'.api_get_cidreq();
  24. switch ($action) {
  25. case 'delete':
  26. DocumentManager::purgeDocument($id, $courseInfo, $sessionId);
  27. Display::addFlash(Display::return_message(get_lang('Deleted')));
  28. header('Location: '.$currentUrl);
  29. exit;
  30. break;
  31. case 'delete_all':
  32. DocumentManager::purgeDocuments($courseInfo, $sessionId);
  33. Display::addFlash(Display::return_message(get_lang('Deleted')));
  34. header('Location: '.$currentUrl);
  35. exit;
  36. break;
  37. case 'download':
  38. DocumentManager::downloadDeletedDocument($id, $courseInfo, $sessionId);
  39. break;
  40. case 'download_all':
  41. DocumentManager::downloadAllDeletedDocument($courseInfo, $sessionId);
  42. break;
  43. }
  44. $interbreadcrumb[] = array(
  45. "url" => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(),
  46. "name" => get_lang('Documents'),
  47. );
  48. $template = new Template(get_lang('DeletedDocuments'));
  49. $template->assign('files', $files);
  50. $template->assign(
  51. 'actions',
  52. Display::toolbarAction('toolbar', [$actions])
  53. );
  54. $template->assign('web_cid_query', api_get_cidreq());
  55. $templateName = $template->get_template('document/recycle.tpl');
  56. $content = $template->fetch($templateName);
  57. $template->assign('content', $content);
  58. $template->display_one_col_template();