lp_content.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 '../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. $dokeos_chapter = false;
  32. foreach ($list as $toc) {
  33. if ($toc['id'] == $lp_item_id &&
  34. ($toc['type'] == 'dokeos_chapter' || $toc['type'] == 'dokeos_module' || $toc['type'] == 'dir')
  35. ) {
  36. $dokeos_chapter = true;
  37. }
  38. }
  39. if ($dokeos_chapter) {
  40. $src = 'blank.php';
  41. } else {
  42. switch ($lp_type) {
  43. case 1:
  44. $_SESSION['oLP']->stop_previous_item();
  45. $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
  46. if ($prereq_check === true) {
  47. $src = $_SESSION['oLP']->get_link('http', $lp_item_id);
  48. $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
  49. $src = $_SESSION['oLP']->fixBlockedLinks($src);
  50. break;
  51. }
  52. $src = 'blank.php?error=prerequisites';
  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(
  95. 'url' => api_get_path(WEB_CODE_PATH).'newscorm/lp_list.php?'.api_get_cidreq(),
  96. 'name' => get_lang('Doc'),
  97. );
  98. // Update global setting to avoid displaying right menu.
  99. $save_setting = api_get_setting('show_navigation_menu');
  100. global $_setting;
  101. $_setting['show_navigation_menu'] = false;
  102. if ($debug > 0) {
  103. error_log('New LP - In lp_content.php - Loading '.$src, 0);
  104. }
  105. header("Location: ".urldecode($src));
  106. exit;