index.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /**
  17. * INIT SECTION
  18. */
  19. // global settings initialisation
  20. // also provides access to main api (inc/lib/main_api.lib.php)
  21. require_once '../inc/global.inc.php';
  22. $htmlHeadXtra[] =
  23. "<script type=\"text/javascript\">
  24. <!-- //
  25. function check_unzip() {
  26. if(document.upload.unzip.checked){
  27. document.upload.if_exists[0].disabled=true;
  28. document.upload.if_exists[1].checked=true;
  29. document.upload.if_exists[2].disabled=true;
  30. }
  31. else {
  32. document.upload.if_exists[0].checked=true;
  33. document.upload.if_exists[0].disabled=false;
  34. document.upload.if_exists[2].disabled=false;
  35. }
  36. }
  37. // -->
  38. </script>";
  39. //$is_allowed_to_edit = api_is_allowed_to_edit();
  40. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  41. if(!$is_allowed_to_edit){
  42. api_not_allowed(true);
  43. }
  44. $courseDir = $_course['path'] . "/document";
  45. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  46. $base_work_dir = $sys_course_path . $courseDir;
  47. $noPHP_SELF = true;
  48. $max_filled_space = DocumentManager::get_course_quota();
  49. //what's the current path?
  50. if (isset($_REQUEST['curdirpath'])) {
  51. $path = $_REQUEST['curdirpath'];
  52. } else {
  53. $path = '/';
  54. }
  55. // set calling tool
  56. if (isset($_REQUEST['tool'])) {
  57. $my_tool = $_REQUEST['tool'];
  58. $_SESSION['my_tool'] = $_REQUEST['tool'];
  59. } elseif (!empty($_SESSION['my_tool'])) {
  60. $my_tool = $_SESSION['my_tool'];
  61. } else {
  62. $my_tool = 'document';
  63. $_SESSION['my_tool'] = $my_tool;
  64. }
  65. /**
  66. * Process
  67. */
  68. Event::event_access_tool(TOOL_UPLOAD);
  69. /**
  70. * Prepare the header
  71. */
  72. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  73. $htmlHeadXtra[] = '<script type="text/javascript">
  74. var myUpload = new upload(0);
  75. </script>';
  76. /**
  77. * Now call the corresponding display script, the current script acting like a controller.
  78. */
  79. switch ($my_tool) {
  80. case TOOL_LEARNPATH:
  81. require('form.scorm.php');
  82. break;
  83. //the following cases need to be distinguished later on
  84. case TOOL_DROPBOX:
  85. case TOOL_STUDENTPUBLICATION:
  86. case TOOL_DOCUMENT:
  87. default:
  88. require('form.document.php');
  89. break;
  90. }