lp_content.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  47. if ($prereq_check === true) {
  48. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  49. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  50. } else {
  51. $src = 'blank.php?error=prerequisites';
  52. }
  53. break;
  54. case 2:
  55. $_SESSION['oLP']->stop_previous_item();
  56. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  57. if ($prereq_check === true) {
  58. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  59. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  60. } else {
  61. $src = 'blank.php?error=prerequisites';
  62. }
  63. break;
  64. case 3:
  65. // save old if asset
  66. $_SESSION['oLP']->stop_previous_item(); // save status manually if asset
  67. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  68. if ($prereq_check === true) {
  69. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  70. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  71. } else {
  72. $src = 'blank.php';
  73. }
  74. break;
  75. case 4:
  76. break;
  77. }
  78. }
  79. if ($debug > 0) {
  80. error_log('New lp - In lp_content.php - File url is '.$src, 0);
  81. }
  82. $_SESSION['oLP']->set_previous_item($lp_item_id);
  83. if (isset($_SESSION['gradebook'])) {
  84. $gradebook = $_SESSION['gradebook'];
  85. }
  86. if (!empty($gradebook) && $gradebook == 'view') {
  87. $interbreadcrumb[] = array(
  88. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  89. 'name' => get_lang('ToolGradebook')
  90. );
  91. }
  92. // Define the 'doc.inc.php' as language file.
  93. $nameTools = $_SESSION['oLP']->get_name();
  94. $interbreadcrumb[] = array('url' => './lp_list.php', 'name' => get_lang('Doc'));
  95. // Update global setting to avoid displaying right menu.
  96. $save_setting = api_get_setting('show_navigation_menu');
  97. global $_setting;
  98. $_setting['show_navigation_menu'] = false;
  99. if ($debug > 0) {
  100. error_log('New LP - In lp_content.php - Loading '.$src, 0);
  101. }
  102. header("Location: ".urldecode($src));