recycle.php 1.9 KB

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