lp_content.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. $learnPath = learnpath::getCurrentLpFromSession();
  10. $debug = 0;
  11. if ($debug > 0) {
  12. error_log('New lp - In lp_content.php', 0);
  13. }
  14. if (empty($lp_controller_touched)) {
  15. if ($debug > 0) {
  16. error_log('New lp - In lp_content.php - Redirecting to lp_controller', 0);
  17. }
  18. 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());
  19. exit;
  20. }
  21. $learnPath->error = '';
  22. $lp_type = $learnPath->get_type();
  23. $lp_item_id = $learnPath->get_current_item_id();
  24. /**
  25. * Get a link to the corresponding document
  26. */
  27. $src = '';
  28. if ($debug > 0) {
  29. error_log('New lp - In lp_content.php - Looking for file url', 0);
  30. }
  31. $list = $learnPath->get_toc();
  32. $dokeos_chapter = false;
  33. foreach ($list as $toc) {
  34. if ($toc['id'] == $lp_item_id && ($toc['type'] == 'dokeos_chapter' || $toc['type'] == 'dokeos_module' || $toc['type'] == 'dir')) {
  35. $dokeos_chapter = true;
  36. }
  37. }
  38. if ($dokeos_chapter) {
  39. $src = 'blank.php';
  40. } else {
  41. switch ($lp_type) {
  42. case 1:
  43. $learnPath->stop_previous_item();
  44. $prereq_check = $learnPath->prerequisites_match($lp_item_id);
  45. if ($prereq_check === true) {
  46. $src = $learnPath->get_link('http', $lp_item_id);
  47. $learnPath->start_current_item(); // starts time counter manually if asset
  48. $src = $learnPath->fixBlockedLinks($src);
  49. break;
  50. }
  51. $src = 'blank.php?error=prerequisites';
  52. break;
  53. case 2:
  54. $learnPath->stop_previous_item();
  55. $prereq_check = $learnPath->prerequisites_match($lp_item_id);
  56. if ($prereq_check === true) {
  57. $src = $learnPath->get_link('http', $lp_item_id);
  58. $learnPath->start_current_item(
  59. ); // 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. $learnPath->stop_previous_item(); // save status manually if asset
  67. $prereq_check = $learnPath->prerequisites_match($lp_item_id);
  68. if ($prereq_check === true) {
  69. $src = $learnPath->get_link('http', $lp_item_id);
  70. $learnPath->start_current_item(
  71. ); // starts time counter manually if asset
  72. } else {
  73. $src = 'blank.php';
  74. }
  75. break;
  76. case 4:
  77. break;
  78. }
  79. }
  80. if ($debug > 0) {
  81. error_log('New lp - In lp_content.php - File url is '.$src, 0);
  82. }
  83. $learnPath->set_previous_item($lp_item_id);
  84. if (api_is_in_gradebook()) {
  85. $interbreadcrumb[]= array(
  86. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
  87. 'name' => get_lang('ToolGradebook')
  88. );
  89. }
  90. // Define the 'doc.inc.php' as language file.
  91. $nameTools = $learnPath->get_name();
  92. $interbreadcrumb[] = array(
  93. 'url' => './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('course.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;