lp_content.php 3.6 KB

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