lp_view_item.php 4.4 KB

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