index.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. //what's the current path?
  37. $path = '/';
  38. if (isset($_REQUEST['curdirpath'])) {
  39. $path = $_REQUEST['curdirpath'];
  40. }
  41. $toolFromSession = Session::read('my_tool');
  42. // set calling tool
  43. if (isset($_REQUEST['tool'])) {
  44. $my_tool = $_REQUEST['tool'];
  45. Session::write('my_tool', $_REQUEST['tool']);
  46. } elseif (!empty($toolFromSession)) {
  47. $my_tool = $toolFromSession;
  48. } else {
  49. $my_tool = 'document';
  50. Session::write('my_tool', $my_tool);
  51. }
  52. /**
  53. * Process.
  54. */
  55. Event::event_access_tool(TOOL_UPLOAD);
  56. /**
  57. * Now call the corresponding display script, the current script acting like a controller.
  58. */
  59. switch ($my_tool) {
  60. case TOOL_LEARNPATH:
  61. require 'form.scorm.php';
  62. break;
  63. //the following cases need to be distinguished later on
  64. case TOOL_DROPBOX:
  65. case TOOL_STUDENTPUBLICATION:
  66. case TOOL_DOCUMENT:
  67. default:
  68. require 'form.document.php';
  69. break;
  70. }