index.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // name of the language file that needs to be included
  20. $language_file[] = "document";
  21. $language_file[] = "scorm";
  22. $language_file[] = "scormdocument";
  23. $language_file[] = "learnpath";
  24. // global settings initialisation
  25. // also provides access to main api (inc/lib/main_api.lib.php)
  26. require_once '../inc/global.inc.php';
  27. $htmlHeadXtra[] =
  28. "<script type=\"text/javascript\">
  29. <!-- //
  30. function check_unzip() {
  31. if(document.upload.unzip.checked){
  32. document.upload.if_exists[0].disabled=true;
  33. document.upload.if_exists[1].checked=true;
  34. document.upload.if_exists[2].disabled=true;
  35. }
  36. else {
  37. document.upload.if_exists[0].checked=true;
  38. document.upload.if_exists[0].disabled=false;
  39. document.upload.if_exists[2].disabled=false;
  40. }
  41. }
  42. // -->
  43. </script>";
  44. //$is_allowed_to_edit = api_is_allowed_to_edit();
  45. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  46. if (!$is_allowed_to_edit) {
  47. api_not_allowed(true);
  48. }
  49. require_once(api_get_path(LIBRARY_PATH).'document.lib.php');
  50. /*
  51. Variables
  52. - some need defining before inclusion of libraries
  53. */
  54. $courseDir = $_course['path']."/document";
  55. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  56. $base_work_dir = $sys_course_path.$courseDir;
  57. $noPHP_SELF = true;
  58. $max_filled_space = DocumentManager::get_course_quota();
  59. //what's the current path?
  60. if (isset($_REQUEST['curdirpath'])) {
  61. $path = $_REQUEST['curdirpath'];
  62. } else {
  63. $path = '/';
  64. }
  65. // set calling tool
  66. if (isset($_REQUEST['tool'])) {
  67. $my_tool = $_REQUEST['tool'];
  68. $_SESSION['my_tool'] = $_REQUEST['tool'];
  69. } elseif (!empty($_SESSION['my_tool'])) {
  70. $my_tool = $_SESSION['my_tool'];
  71. } else {
  72. $my_tool = 'document';
  73. $_SESSION['my_tool'] = $my_tool;
  74. }
  75. // Check the path
  76. // If the path is not found (no document id), set the path to /
  77. //if(!DocumentManager::get_document_id($_course,$path)) { $path = '/'; }
  78. //$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($path).$req_gid, "name"=> $langDocuments);
  79. /**
  80. * Process
  81. */
  82. event_access_tool(TOOL_UPLOAD);
  83. /**
  84. * Prepare the header
  85. */
  86. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  87. $htmlHeadXtra[] = '<script type="text/javascript">
  88. var myUpload = new upload(0);
  89. </script>';
  90. /**
  91. * Now call the corresponding display script, the current script acting like a controller.
  92. */
  93. switch ($my_tool) {
  94. case TOOL_LEARNPATH:
  95. require('form.scorm.php');
  96. break;
  97. //the following cases need to be distinguished later on
  98. case TOOL_DROPBOX:
  99. case TOOL_STUDENTPUBLICATION:
  100. case TOOL_DOCUMENT:
  101. default:
  102. require('form.document.php');
  103. break;
  104. }