lp_view_item.php 4.8 KB

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