lp_view_item.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. /**
  13. * Code
  14. */
  15. // Prevents FF 3.6 + Adobe Reader 9 bug see BT#794 when calling a pdf file in a LP
  16. // The main_api.lib.php, database.lib.php and display.lib.php
  17. // libraries are included by default.
  18. require_once 'back_compat.inc.php';
  19. require_once 'scorm.lib.php';
  20. require_once 'learnpath.class.php';
  21. require_once 'learnpathItem.class.php';
  22. require_once 'learnpath_functions.inc.php';
  23. //include '../resourcelinker/resourcelinker.inc.php';
  24. require_once 'resourcelinker.inc.php';
  25. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  26. // name of the language file that needs to be included
  27. // Including the global initialization file.
  28. require_once '../inc/global.inc.php';
  29. api_protect_course_script();
  30. if (isset($_GET['lp_item_id'])) {
  31. // Get parameter only came from lp_view.php.
  32. $lp_item_id = intval($_GET['lp_item_id']);
  33. if (isset($_SESSION['lpobject'])) {
  34. $oLP = unserialize($_SESSION['lpobject']);
  35. }
  36. if (is_object($oLP)) {
  37. $src = $oLP->get_link('http', $lp_item_id);
  38. }
  39. $url_info = parse_url($src);
  40. $real_url_info = parse_url(api_get_path(WEB_PATH));
  41. // The host must be the same.
  42. if ($url_info['host'] == $real_url_info['host']) {
  43. $url = Security::remove_XSS($src);
  44. header("Location: ".$url);
  45. exit;
  46. } else {
  47. header("Location: blank.php?error=document_not_found");
  48. exit;
  49. }
  50. }
  51. /* INIT SECTION */
  52. $_SESSION['whereami'] = 'lp/build';
  53. if (isset($_SESSION['oLP']) && isset($_GET['id'])) {
  54. $_SESSION['oLP'] -> current = intval($_GET['id']);
  55. }
  56. $this_section=SECTION_COURSES;
  57. /* Libraries */
  58. $language_file = "learnpath";
  59. /* Header and action code */
  60. /* Constants and variables */
  61. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  62. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  63. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  64. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  65. $isStudentView = (empty($_REQUEST['isStudentView']) ? 0 : (int) $_REQUEST['isStudentView']);
  66. $learnpath_id = (int) $_REQUEST['lp_id'];
  67. // Using the resource linker as a tool for adding resources to the learning path.
  68. if ($action == 'add' && $type == 'learnpathitem') {
  69. $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
  70. }
  71. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  72. error_log('New LP - User not authorized in lp_view_item.php');
  73. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  74. exit;
  75. }
  76. // From here on, we are admin because of the previous condition, so don't check anymore.
  77. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  78. $result=Database::query($sql_query);
  79. $therow=Database::fetch_array($result);
  80. /* SHOWING THE ADMIN TOOLS */
  81. if (isset($_SESSION['gradebook'])) {
  82. $gradebook = $_SESSION['gradebook'];
  83. }
  84. if (!empty($gradebook) && $gradebook == 'view') {
  85. $interbreadcrumb[] = array (
  86. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  87. 'name' => get_lang('ToolGradebook')
  88. );
  89. }
  90. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  91. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $therow['name']);
  92. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Item'));
  93. // Theme calls
  94. $show_learn_path = true;
  95. if (isset($_SESSION['oLP']) && is_object($_SESSION['oLP'])) {
  96. $lp_theme_css = $_SESSION['oLP']->get_theme();
  97. }
  98. Display::display_header(null,'Path');
  99. //api_display_tool_title($therow['name']);
  100. $suredel = trim(get_lang('AreYouSureToDelete'));
  101. ?>
  102. <script type='text/javascript'>
  103. /* <![CDATA[ */
  104. function stripslashes(str) {
  105. str=str.replace(/\\'/g,'\'');
  106. str=str.replace(/\\"/g,'"');
  107. str=str.replace(/\\\\/g,'\\');
  108. str=str.replace(/\\0/g,'\0');
  109. return str;
  110. }
  111. function confirmation(name) {
  112. name=stripslashes(name);
  113. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  114. return true;
  115. } else {
  116. return false;
  117. }
  118. }
  119. </script>
  120. <?php
  121. if (is_object($_SESSION['oLP'])) {
  122. echo $_SESSION['oLP']->build_action_menu();
  123. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  124. echo '<tr>';
  125. echo '<td class="tree">';
  126. echo '<div class="lp_tree">';
  127. // Build the tree with the menu items in it.
  128. echo $_SESSION['oLP']->build_tree();
  129. echo '</div>';
  130. echo '</td>';
  131. echo '<td class="workspace">';
  132. echo $_SESSION['oLP']->display_item((isset($new_item_id)) ? $new_item_id : $_GET['id']);
  133. echo '</td>';
  134. echo '</tr>';
  135. echo '</table>';
  136. }
  137. Display::display_footer();