lp_content.php 3.6 KB

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