dokeos-upload
[ class tree: dokeos-upload ] [ index: dokeos-upload ] [ all elements ]

Source for file index.php

Documentation is available at index.php

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

Documentation generated on Thu, 12 Jun 2008 13:50:12 -0500 by phpDocumentor 1.4.1