lp_view_item.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. require_once '../inc/global.inc.php';
  17. require_once 'learnpath.class.php';
  18. require_once 'learnpathItem.class.php';
  19. require_once 'learnpath_functions.inc.php';
  20. require_once 'resourcelinker.inc.php';
  21. api_protect_course_script();
  22. if (isset($_GET['lp_item_id'])) {
  23. // Get parameter only came from lp_view.php.
  24. $lp_item_id = intval($_GET['lp_item_id']);
  25. if (isset($_SESSION['lpobject'])) {
  26. $oLP = unserialize($_SESSION['lpobject']);
  27. }
  28. if (is_object($oLP)) {
  29. $src = $oLP->get_link('http', $lp_item_id);
  30. }
  31. $url_info = parse_url($src);
  32. $real_url_info = parse_url(api_get_path(WEB_PATH));
  33. // The host must be the same.
  34. if ($url_info['host'] == $real_url_info['host']) {
  35. $url = Security::remove_XSS($src);
  36. header("Location: ".$url);
  37. exit;
  38. } else {
  39. header("Location: blank.php?error=document_not_found");
  40. exit;
  41. }
  42. }
  43. $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'fullpage';
  44. /* INIT SECTION */
  45. $_SESSION['whereami'] = 'lp/build';
  46. if (isset($_SESSION['oLP']) && isset($_GET['id'])) {
  47. $_SESSION['oLP'] -> current = intval($_GET['id']);
  48. }
  49. $this_section = SECTION_COURSES;
  50. $language_file = "learnpath";
  51. /* Header and action code */
  52. /* Constants and variables */
  53. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  54. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  55. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  56. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  57. $isStudentView = (empty($_REQUEST['isStudentView']) ? 0 : (int) $_REQUEST['isStudentView']);
  58. $learnpath_id = (int) $_REQUEST['lp_id'];
  59. // Using the resource linker as a tool for adding resources to the learning path.
  60. if ($action == 'add' && $type == 'learnpathitem') {
  61. $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
  62. }
  63. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  64. error_log('New LP - User not authorized in lp_view_item.php');
  65. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  66. exit;
  67. }
  68. // From here on, we are admin because of the previous condition, so don't check anymore.
  69. $course_id = api_get_course_int_id();
  70. $sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  71. $result=Database::query($sql_query);
  72. $therow=Database::fetch_array($result);
  73. /* SHOWING THE ADMIN TOOLS */
  74. if (isset($_SESSION['gradebook'])) {
  75. $gradebook = $_SESSION['gradebook'];
  76. }
  77. if (!empty($gradebook) && $gradebook == 'view') {
  78. $interbreadcrumb[] = array (
  79. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  80. 'name' => get_lang('ToolGradebook')
  81. );
  82. }
  83. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  84. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $therow['name']);
  85. $interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
  86. // Theme calls
  87. $show_learn_path = true;
  88. if (isset($_SESSION['oLP']) && is_object($_SESSION['oLP'])) {
  89. $lp_theme_css = $_SESSION['oLP']->get_theme();
  90. }
  91. if ($mode == 'fullpage') {
  92. Display::display_header(get_lang('Item'),'Path');
  93. }
  94. $suredel = trim(get_lang('AreYouSureToDelete'));
  95. ?>
  96. <script>
  97. /* <![CDATA[ */
  98. function stripslashes(str) {
  99. str=str.replace(/\\'/g,'\'');
  100. str=str.replace(/\\"/g,'"');
  101. str=str.replace(/\\\\/g,'\\');
  102. str=str.replace(/\\0/g,'\0');
  103. return str;
  104. }
  105. function confirmation(name) {
  106. name=stripslashes(name);
  107. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  108. return true;
  109. } else {
  110. return false;
  111. }
  112. }
  113. </script>
  114. <?php
  115. $id = (isset($new_item_id)) ? $new_item_id : $_GET['id'];
  116. if (is_object($_SESSION['oLP'])) {
  117. switch ($mode) {
  118. case 'fullpage':
  119. echo $_SESSION['oLP']->build_action_menu();
  120. echo '<div class="row-fluid">';
  121. echo '<div class="span3">';
  122. echo $_SESSION['oLP']->return_new_tree();
  123. echo '</div>';
  124. echo '<div class="span9">';
  125. echo $_SESSION['oLP']->display_item($id);
  126. echo '</div>';
  127. echo '</div>';
  128. break;
  129. case 'preview_document':
  130. $app['template.show_header'] = false;
  131. $app['template.show_footer'] = false;
  132. echo $_SESSION['oLP']->display_item($id, null, false);
  133. break;
  134. }
  135. }