index.php 3.0 KB

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