download.lib.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Course info library
  5. * @package chamilo.course_info
  6. */
  7. /**
  8. * Code
  9. */
  10. // TODO: Where this file is used? Is it needed at all?
  11. //require '../inc/global.inc.php';
  12. function create_backup_is_admin($_cid) {
  13. $this_section = SECTION_COURSES;
  14. if (isset($_GET['session']) && $_GET['session']) {
  15. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  16. $_cid = true;
  17. $is_courseAdmin = true;
  18. } else {
  19. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  20. }
  21. $archive_file = $_GET['archive'];
  22. $archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
  23. list($extension) = getextension($archive_file);
  24. if (empty($extension) || !file_exists($archive_path.$archive_file)) {
  25. return false;
  26. }
  27. $extension = strtolower($extension);
  28. $content_type = '';
  29. if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
  30. $content_type = 'application/force-download';
  31. // TODO: The following unclear condition is commented ant is to be checked. A replacement has been proposed.
  32. //} elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) {
  33. } elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
  34. //
  35. $content_type = 'application/force-download';
  36. }
  37. if (empty($content_type)) {
  38. return false;
  39. }
  40. return true;
  41. }
  42. return true; // TODO: Why is this line here?