index.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Main script for the documents tool
  6. *
  7. * This script allows the user to manage files and directories on a remote http server.
  8. *
  9. * The user can : - upload a file
  10. *
  11. * The script respects the strategical split between process and display, so the first
  12. * part is only processing code (init, process, display preparation) and the second
  13. * part is only display (HTML)
  14. *
  15. * @package chamilo.upload
  16. */
  17. require_once __DIR__.'/../inc/global.inc.php';
  18. $_course = api_get_course_info();
  19. $htmlHeadXtra[] = "<script>
  20. function check_unzip() {
  21. if(document.upload.unzip.checked){
  22. document.upload.if_exists[0].disabled=true;
  23. document.upload.if_exists[1].checked=true;
  24. document.upload.if_exists[2].disabled=true;
  25. } else {
  26. document.upload.if_exists[0].checked=true;
  27. document.upload.if_exists[0].disabled=false;
  28. document.upload.if_exists[2].disabled=false;
  29. }
  30. }
  31. </script>";
  32. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  33. if (!$is_allowed_to_edit) {
  34. api_not_allowed(true);
  35. }
  36. $courseDir = $_course['path']."/document";
  37. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  38. $base_work_dir = $sys_course_path.$courseDir;
  39. $noPHP_SELF = true;
  40. $max_filled_space = DocumentManager::get_course_quota();
  41. //what's the current path?
  42. if (isset($_REQUEST['curdirpath'])) {
  43. $path = $_REQUEST['curdirpath'];
  44. } else {
  45. $path = '/';
  46. }
  47. $toolFromSession = Session::read('my_tool');
  48. // set calling tool
  49. if (isset($_REQUEST['tool'])) {
  50. $my_tool = $_REQUEST['tool'];
  51. Session::write('my_tool', $_REQUEST['tool']);
  52. } elseif (!empty($toolFromSession)) {
  53. $my_tool = $toolFromSession;
  54. } else {
  55. $my_tool = 'document';
  56. Session::write('my_tool', $my_tool);
  57. }
  58. /**
  59. * Process
  60. */
  61. Event::event_access_tool(TOOL_UPLOAD);
  62. /**
  63. * Prepare the header
  64. */
  65. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  66. $htmlHeadXtra[] = '<script>
  67. var myUpload = new upload(0);
  68. </script>';
  69. /**
  70. * Now call the corresponding display script, the current script acting like a controller.
  71. */
  72. switch ($my_tool) {
  73. case TOOL_LEARNPATH:
  74. require 'form.scorm.php';
  75. break;
  76. //the following cases need to be distinguished later on
  77. case TOOL_DROPBOX:
  78. case TOOL_STUDENTPUBLICATION:
  79. case TOOL_DOCUMENT:
  80. default:
  81. require 'form.document.php';
  82. break;
  83. }