lp_content.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script that displays an error message when no content could be loaded
  5. * @package chamilo.learnpath
  6. * @author Yannick Warnier <ywarnier@beeznest.org>
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. $debug = 0;
  10. if ($debug > 0) {
  11. error_log('New lp - In lp_content.php', 0);
  12. }
  13. if (empty($lp_controller_touched)) {
  14. if ($debug > 0) {
  15. error_log('New lp - In lp_content.php - Redirecting to lp_controller', 0);
  16. }
  17. header('location: lp_controller.php?action=content&lp_id='.intval($_REQUEST['lp_id']).'&item_id='.intval($_REQUEST['item_id']).'&'.api_get_cidreq());
  18. exit;
  19. }
  20. $_SESSION['oLP']->error = '';
  21. $lp_type = $_SESSION['oLP']->get_type();
  22. $lp_item_id = $_SESSION['oLP']->get_current_item_id();
  23. /**
  24. * Get a link to the corresponding document
  25. */
  26. $src = '';
  27. if ($debug > 0) {
  28. error_log('New lp - In lp_content.php - Looking for file url', 0);
  29. }
  30. $list = $_SESSION['oLP']->get_toc();
  31. $dir = false;
  32. foreach ($list as $toc) {
  33. if ($toc['id'] == $lp_item_id && $toc['type'] == 'dir') {
  34. $dir = true;
  35. }
  36. }
  37. if ($dir) {
  38. $src = 'blank.php';
  39. } else {
  40. switch ($lp_type) {
  41. case 1:
  42. $_SESSION['oLP']->stop_previous_item();
  43. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  44. if ($prereq_check === true) {
  45. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  46. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  47. $src = $_SESSION['oLP']->fixBlockedLinks($src);
  48. break;
  49. }
  50. $src = 'blank.php?error=prerequisites';
  51. break;
  52. case 2:
  53. $_SESSION['oLP']->stop_previous_item();
  54. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  55. if ($prereq_check === true) {
  56. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  57. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  58. } else {
  59. $src = 'blank.php?error=prerequisites';
  60. }
  61. break;
  62. case 3:
  63. // save old if asset
  64. $_SESSION['oLP']->stop_previous_item(); // save status manually if asset
  65. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  66. if ($prereq_check === true) {
  67. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  68. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  69. } else {
  70. $src = 'blank.php';
  71. }
  72. break;
  73. case 4:
  74. break;
  75. }
  76. }
  77. if ($debug > 0) {
  78. error_log('New lp - In lp_content.php - File url is '.$src, 0);
  79. }
  80. $_SESSION['oLP']->set_previous_item($lp_item_id);
  81. if (isset($_SESSION['gradebook'])) {
  82. $gradebook = $_SESSION['gradebook'];
  83. }
  84. if (!empty($gradebook) && $gradebook == 'view') {
  85. $interbreadcrumb[] = array(
  86. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  87. 'name' => get_lang('ToolGradebook')
  88. );
  89. }
  90. // Define the 'doc.inc.php' as language file.
  91. $nameTools = $_SESSION['oLP']->get_name();
  92. $interbreadcrumb[] = array(
  93. 'url' => api_get_path(WEB_CODE_PATH).'lp/lp_list.php?'.api_get_cidreq(),
  94. 'name' => get_lang('Doc'),
  95. );
  96. // Update global setting to avoid displaying right menu.
  97. $save_setting = api_get_setting('show_navigation_menu');
  98. global $_setting;
  99. $_setting['show_navigation_menu'] = false;
  100. if ($debug > 0) {
  101. error_log('New LP - In lp_content.php - Loading '.$src, 0);
  102. }
  103. header("Location: ".urldecode($src));
  104. exit;