lp_view_item.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is a learning path creation and player tool in Dokeos - 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 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. /*
  37. Libraries
  38. */
  39. //the main_api.lib.php, database.lib.php and display.lib.php
  40. //libraries are included by default
  41. require_once 'learnpath_functions.inc.php';
  42. //include('../resourcelinker/resourcelinker.inc.php');
  43. require_once 'resourcelinker.inc.php';
  44. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  45. // name of the language file that needs to be included
  46. $language_file = "learnpath";
  47. /* Header and action code */
  48. /* Constants and variables */
  49. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  50. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  51. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  52. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  53. $isStudentView = (empty($_REQUEST['isStudentView'])?0:(int) $_REQUEST['isStudentView']);
  54. $learnpath_id = (int) $_REQUEST['lp_id'];
  55. /*
  56. $chapter_id = $_GET['chapter_id'];
  57. $title = $_POST['title'];
  58. $description = $_POST['description'];
  59. $Submititem = $_POST['Submititem'];
  60. $action = $_REQUEST['action'];
  61. $id = (int) $_REQUEST['id'];
  62. $type = $_REQUEST['type'];
  63. $direction = $_REQUEST['direction'];
  64. $moduleid = $_REQUEST['moduleid'];
  65. $prereq = $_REQUEST['prereq'];
  66. $type = $_REQUEST['type'];
  67. */
  68. /*
  69. MAIN CODE
  70. */
  71. // using the resource linker as a tool for adding resources to the learning path
  72. if ($action=="add" and $type=="learnpathitem")
  73. {
  74. $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>";
  75. }
  76. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  77. {
  78. error_log('New LP - User not authorized in lp_view_item.php');
  79. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  80. }
  81. //from here on, we are admin because of the previous condition, so don't check anymore
  82. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  83. $result=Database::query($sql_query);
  84. $therow=Database::fetch_array($result);
  85. //$admin_output = '';
  86. /*
  87. -----------------------------------------------------------
  88. Course admin section
  89. - all the functions not available for students - always available in this case (page only shown to admin)
  90. -----------------------------------------------------------
  91. */
  92. /* SHOWING THE ADMIN TOOLS */
  93. /* prerequisites setting end */
  94. if (isset($_SESSION['gradebook'])){
  95. $gradebook= $_SESSION['gradebook'];
  96. }
  97. if (!empty($gradebook) && $gradebook=='view') {
  98. $interbreadcrumb[]= array (
  99. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  100. 'name' => get_lang('ToolGradebook')
  101. );
  102. }
  103. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  104. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  105. //Theme calls
  106. $show_learn_path=true;
  107. $lp_theme_css=$_SESSION['oLP']->get_theme();
  108. Display::display_header(null,'Path');
  109. //api_display_tool_title($therow['name']);
  110. $suredel = trim(get_lang('AreYouSureToDelete'));
  111. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  112. ?>
  113. <script type='text/javascript'>
  114. /* <![CDATA[ */
  115. function stripslashes(str) {
  116. str=str.replace(/\\'/g,'\'');
  117. str=str.replace(/\\"/g,'"');
  118. str=str.replace(/\\\\/g,'\\');
  119. str=str.replace(/\\0/g,'\0');
  120. return str;
  121. }
  122. function confirmation(name) {
  123. name=stripslashes(name);
  124. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  125. return true;
  126. } else {
  127. return false;
  128. }
  129. }
  130. </script>
  131. <?php
  132. //echo $admin_output;
  133. /* DISPLAY SECTION */
  134. echo $_SESSION['oLP']->build_action_menu();
  135. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  136. echo '<tr>';
  137. echo '<td class="tree">';
  138. echo '<div class="lp_tree">';
  139. //build the tree with the menu items in it
  140. echo $_SESSION['oLP']->build_tree();
  141. echo '</div>';
  142. echo '</td>';
  143. echo '<td class="workspace">';
  144. echo $_SESSION['oLP']->display_item((isset($new_item_id)) ? $new_item_id : $_GET['id']);
  145. echo '</td>';
  146. echo '</tr>';
  147. echo '</table>';
  148. /* FOOTER */
  149. Display::display_footer();
  150. ?>