lp_content.php 3.6 KB

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