index.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. /*
  50. Libraries
  51. */
  52. //many useful functions in main_api.lib.php, by default included
  53. require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
  54. require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
  55. /*
  56. Variables
  57. - some need defining before inclusion of libraries
  58. */
  59. $courseDir = $_course['path']."/document";
  60. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  61. $base_work_dir = $sys_course_path.$courseDir;
  62. $noPHP_SELF=true;
  63. $max_filled_space = DocumentManager::get_course_quota();
  64. //what's the current path?
  65. if(isset($_REQUEST['curdirpath'])) {
  66. $path = $_REQUEST['curdirpath'];
  67. }else{
  68. $path = '/';
  69. }
  70. // set calling tool
  71. if(isset($_REQUEST['tool'])) {
  72. $my_tool = $_REQUEST['tool'];
  73. $_SESSION['my_tool'] = $_REQUEST['tool'];
  74. }elseif(!empty($_SESSION['my_tool'])){
  75. $my_tool = $_SESSION['my_tool'];
  76. }else{
  77. $my_tool = 'document';
  78. $_SESSION['my_tool'] = $my_tool;
  79. }
  80. // Check the path
  81. // If the path is not found (no document id), set the path to /
  82. //if(!DocumentManager::get_document_id($_course,$path)) { $path = '/'; }
  83. //$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($path).$req_gid, "name"=> $langDocuments);
  84. /**
  85. * Process
  86. */
  87. event_access_tool(TOOL_UPLOAD);
  88. /**
  89. * Prepare the header
  90. */
  91. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  92. $htmlHeadXtra[] = '<script type="text/javascript">
  93. var myUpload = new upload(0);
  94. </script>';
  95. /**
  96. * Now call the corresponding display script, the current script acting like a controller.
  97. */
  98. switch($my_tool){
  99. case TOOL_LEARNPATH:
  100. require('form.scorm.php');
  101. break;
  102. //the following cases need to be distinguished later on
  103. case TOOL_DROPBOX:
  104. case TOOL_STUDENTPUBLICATION:
  105. case TOOL_DOCUMENT:
  106. default:
  107. require('form.document.php');
  108. break;
  109. }