lp_view_item.php 5.3 KB

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