index.php 2.4 KB

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