index.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Main script for the documents tool
  6. *
  7. * This script allows the user to manage files and directories on a remote http server.
  8. *
  9. * The user can : - upload a file
  10. *
  11. * The script respects the strategical split between process and display, so the first
  12. * part is only processing code (init, process, display preparation) and the second
  13. * part is only display (HTML)
  14. *
  15. * @package chamilo.upload
  16. */
  17. require_once __DIR__.'/../inc/global.inc.php';
  18. $_course = api_get_course_info();
  19. $htmlHeadXtra[] = "<script>
  20. function check_unzip() {
  21. if(document.upload.unzip.checked){
  22. document.upload.if_exists[0].disabled=true;
  23. document.upload.if_exists[1].checked=true;
  24. document.upload.if_exists[2].disabled=true;
  25. } else {
  26. document.upload.if_exists[0].checked=true;
  27. document.upload.if_exists[0].disabled=false;
  28. document.upload.if_exists[2].disabled=false;
  29. }
  30. }
  31. </script>";
  32. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  33. if (!$is_allowed_to_edit) {
  34. api_not_allowed(true);
  35. }
  36. $noPHP_SELF = true;
  37. //what's the current path?
  38. if (isset($_REQUEST['curdirpath'])) {
  39. $path = $_REQUEST['curdirpath'];
  40. } else {
  41. $path = '/';
  42. }
  43. $toolFromSession = Session::read('my_tool');
  44. // set calling tool
  45. if (isset($_REQUEST['tool'])) {
  46. $my_tool = $_REQUEST['tool'];
  47. Session::write('my_tool', $_REQUEST['tool']);
  48. } elseif (!empty($toolFromSession)) {
  49. $my_tool = $toolFromSession;
  50. } else {
  51. $my_tool = 'document';
  52. Session::write('my_tool', $my_tool);
  53. }
  54. /**
  55. * Process
  56. */
  57. Event::event_access_tool(TOOL_UPLOAD);
  58. /**
  59. * Prepare the header
  60. */
  61. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  62. $htmlHeadXtra[] = '<script>
  63. var myUpload = new upload(0);
  64. </script>';
  65. /**
  66. * Now call the corresponding display script, the current script acting like a controller.
  67. */
  68. switch ($my_tool) {
  69. case TOOL_LEARNPATH:
  70. require 'form.scorm.php';
  71. break;
  72. //the following cases need to be distinguished later on
  73. case TOOL_DROPBOX:
  74. case TOOL_STUDENTPUBLICATION:
  75. case TOOL_DOCUMENT:
  76. default:
  77. require 'form.document.php';
  78. break;
  79. }