lp_content.php 3.9 KB

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