index.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php // $Id$
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2006 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. * Main script for the documents tool
  21. *
  22. * This script allows the user to manage files and directories on a remote http server.
  23. *
  24. * The user can : - upload a file
  25. *
  26. * The script respects the strategical split between process and display, so the first
  27. * part is only processing code (init, process, display preparation) and the second
  28. * part is only display (HTML)
  29. *
  30. * @package dokeos.upload
  31. */
  32. /**
  33. * INIT SECTION
  34. */
  35. // name of the language file that needs to be included
  36. $language_file[] = "document";
  37. $language_file[] = "scorm";
  38. $language_file[] = "scormdocument";
  39. // global settings initialisation
  40. // also provides access to main api (inc/lib/main_api.lib.php)
  41. include("../inc/global.inc.php");
  42. $htmlHeadXtra[] =
  43. "<script type=\"text/javascript\">
  44. <!-- //
  45. function check_unzip() {
  46. if(document.upload.unzip.checked==true){
  47. document.upload.if_exists[0].disabled=true;
  48. document.upload.if_exists[1].checked=true;
  49. document.upload.if_exists[2].disabled=true;
  50. }
  51. else {
  52. document.upload.if_exists[0].checked=true;
  53. document.upload.if_exists[0].disabled=false;
  54. document.upload.if_exists[2].disabled=false;
  55. }
  56. }
  57. // -->
  58. </script>";
  59. $is_allowed_to_edit = api_is_allowed_to_edit();
  60. if(!$is_allowed_to_edit){
  61. api_not_allowed(true);
  62. }
  63. /*
  64. -----------------------------------------------------------
  65. Libraries
  66. -----------------------------------------------------------
  67. */
  68. //many useful functions in main_api.lib.php, by default included
  69. require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
  70. require_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
  71. require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
  72. /*
  73. -----------------------------------------------------------
  74. Variables
  75. - some need defining before inclusion of libraries
  76. -----------------------------------------------------------
  77. */
  78. $courseDir = $_course['path']."/document";
  79. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  80. $base_work_dir = $sys_course_path.$courseDir;
  81. $noPHP_SELF=true;
  82. $max_filled_space = DocumentManager::get_course_quota();
  83. //what's the current path?
  84. if(isset($_REQUEST['curdirpath'])) {
  85. $path = $_REQUEST['curdirpath'];
  86. }else{
  87. $path = '/';
  88. }
  89. // set calling tool
  90. if(isset($_REQUEST['tool'])) {
  91. $my_tool = $_REQUEST['tool'];
  92. $_SESSION['my_tool'] = $_REQUEST['tool'];
  93. }elseif(!empty($_SESSION['my_tool'])){
  94. $my_tool = $_SESSION['my_tool'];
  95. }else{
  96. $my_tool = 'document';
  97. $_SESSION['my_tool'] = $my_tool;
  98. }
  99. // Check the path
  100. // If the path is not found (no document id), set the path to /
  101. //if(!DocumentManager::get_document_id($_course,$path)) { $path = '/'; }
  102. //$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($path).$req_gid, "name"=> $langDocuments);
  103. /**
  104. * Process
  105. */
  106. event_access_tool(TOOL_UPLOAD);
  107. /**
  108. * Prepare the header
  109. */
  110. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  111. $htmlHeadXtra[] = '<script type="text/javascript">
  112. var myUpload = new upload(0);
  113. </script>';
  114. /**
  115. * Now call the corresponding display script, the current script acting like a controller.
  116. */
  117. switch($my_tool){
  118. case TOOL_LEARNPATH:
  119. require('form.scorm.php');
  120. break;
  121. //the following cases need to be distinguished later on
  122. case TOOL_DROPBOX:
  123. case TOOL_STUDENTPUBLICATION:
  124. case TOOL_DOCUMENT:
  125. default:
  126. require('form.document.php');
  127. break;
  128. }