lp_view_item.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php.
  6. *
  7. * @author Patrick Cool
  8. * @author Denes Nagy
  9. * @author Roan Embrechts, refactoring and code cleaning
  10. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  11. *
  12. * @package chamilo.learnpath
  13. */
  14. // Prevents FF 3.6 + Adobe Reader 9 bug see BT#794 when calling a pdf file in a LP
  15. require_once __DIR__.'/../inc/global.inc.php';
  16. api_protect_course_script();
  17. /** @var learnpath $lp */
  18. $lp = Session::read('oLP');
  19. if (isset($_GET['lp_item_id'])) {
  20. // Get parameter only came from lp_view.php.
  21. $lp_item_id = (int) $_GET['lp_item_id'];
  22. if (is_object($lp)) {
  23. $src = $lp->get_link('http', $lp_item_id);
  24. }
  25. $url_info = parse_url($src);
  26. $real_url_info = parse_url(api_get_path(WEB_PATH));
  27. // The host must be the same.
  28. if ($url_info['host'] == $real_url_info['host']) {
  29. $url = Security::remove_XSS($src);
  30. header("Location: ".$url);
  31. exit;
  32. } else {
  33. header("Location: blank.php?error=document_not_found");
  34. exit;
  35. }
  36. }
  37. if (empty($lp)) {
  38. api_not_allowed();
  39. }
  40. $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'fullpage';
  41. if (isset($_SESSION['oLP']) && isset($_GET['id'])) {
  42. $_SESSION['oLP']->current = intval($_GET['id']);
  43. }
  44. $this_section = SECTION_COURSES;
  45. /* Header and action code */
  46. /* Constants and variables */
  47. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  48. $isStudentView = (empty($_REQUEST['isStudentView']) ? 0 : (int) $_REQUEST['isStudentView']);
  49. $learnpath_id = (int) $_REQUEST['lp_id'];
  50. if (!$is_allowed_to_edit || $isStudentView) {
  51. header('Location: '.api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=view&lp_id='.$learnpath_id.'&'.api_get_cidreq());
  52. exit;
  53. }
  54. // From here on, we are admin because of the previous condition, so don't check anymore.
  55. $course_id = api_get_course_int_id();
  56. /* SHOWING THE ADMIN TOOLS */
  57. if (api_is_in_gradebook()) {
  58. $interbreadcrumb[] = [
  59. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
  60. 'name' => get_lang('ToolGradebook'),
  61. ];
  62. }
  63. $interbreadcrumb[] = [
  64. 'url' => api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=list&'.api_get_cidreq(),
  65. 'name' => get_lang('LearningPaths'),
  66. ];
  67. $interbreadcrumb[] = [
  68. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  69. 'name' => $lp->get_name(),
  70. ];
  71. $interbreadcrumb[] = [
  72. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  73. 'name' => get_lang('NewStep'),
  74. ];
  75. // Theme calls
  76. $show_learn_path = true;
  77. $lp_theme_css = $lp->get_theme();
  78. if ($mode == 'fullpage') {
  79. Display::display_header(get_lang('Item'), 'Path');
  80. }
  81. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  82. ?>
  83. <script>
  84. function stripslashes(str) {
  85. str=str.replace(/\\'/g,'\'');
  86. str=str.replace(/\\"/g,'"');
  87. str=str.replace(/\\\\/g,'\\');
  88. str=str.replace(/\\0/g,'\0');
  89. return str;
  90. }
  91. function confirmation(name) {
  92. name=stripslashes(name);
  93. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  94. return true;
  95. } else {
  96. return false;
  97. }
  98. }
  99. </script>
  100. <?php
  101. $id = isset($new_item_id) ? $new_item_id : $_GET['id'];
  102. if (is_object($lp)) {
  103. switch ($mode) {
  104. case 'fullpage':
  105. echo $lp->build_action_menu();
  106. echo '<div class="row">';
  107. echo '<div class="col-md-3">';
  108. echo $lp->return_new_tree();
  109. echo '</div>';
  110. echo '<div class="col-md-9">';
  111. echo $lp->display_item($id);
  112. echo '</div>';
  113. echo '</div>';
  114. Display::display_footer();
  115. break;
  116. case 'preview_document':
  117. echo $lp->display_item($id, null, false);
  118. break;
  119. }
  120. }