lp_edit_item_prereq.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. $this_section = SECTION_COURSES;
  13. api_protect_course_script();
  14. /* Libraries */
  15. include 'learnpath_functions.inc.php';
  16. //include '../resourcelinker/resourcelinker.inc.php';
  17. include 'resourcelinker.inc.php';
  18. // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
  19. // Name of the language file that needs to be included.
  20. $language_file = 'learnpath';
  21. /* Constants and variables */
  22. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  23. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  24. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  25. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  26. $isStudentView = (int) $_REQUEST['isStudentView'];
  27. $learnpath_id = (int) $_REQUEST['lp_id'];
  28. $submit = $_POST['submit_button'];
  29. /* MAIN CODE */
  30. // Using the resource linker as a tool for adding resources to the learning path.
  31. if ($action == 'add' and $type == 'learnpathitem') {
  32. $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>";
  33. }
  34. if ((! $is_allowed_to_edit) || ($isStudentView)) {
  35. error_log('New LP - User not authorized in lp_edit_item_prereq.php');
  36. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  37. }
  38. // From here on, we are admin because of the previous condition, so don't check anymore.
  39. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  40. $result = Database::query($sql_query);
  41. $therow = Database::fetch_array($result);
  42. //$admin_output = '';
  43. /*
  44. Course admin section
  45. - all the functions not available for students - always available in this case (page only shown to admin)
  46. */
  47. /* SHOWING THE ADMIN TOOLS */
  48. if (isset($_SESSION['gradebook'])){
  49. $gradebook = $_SESSION['gradebook'];
  50. }
  51. if (!empty($gradebook) && $gradebook == 'view') {
  52. $interbreadcrumb[] = array (
  53. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  54. 'name' => get_lang('ToolGradebook')
  55. );
  56. }
  57. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  58. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  59. // Theme calls.
  60. $show_learn_path = true;
  61. $lp_theme_css = $_SESSION['oLP']->get_theme();
  62. Display::display_header(null,'Path');
  63. //api_display_tool_title($therow['name']);
  64. $suredel = trim(get_lang('AreYouSureToDelete'));
  65. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  66. ?>
  67. <script type='text/javascript'>
  68. /* <![CDATA[ */
  69. function stripslashes(str) {
  70. str=str.replace(/\\'/g,'\'');
  71. str=str.replace(/\\"/g,'"');
  72. str=str.replace(/\\\\/g,'\\');
  73. str=str.replace(/\\0/g,'\0');
  74. return str;
  75. }
  76. function confirmation(name)
  77. {
  78. name=stripslashes(name);
  79. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  80. {
  81. return true;
  82. }
  83. else
  84. {
  85. return false;
  86. }
  87. }
  88. </script>
  89. <?php
  90. //echo $admin_output;
  91. /* DISPLAY SECTION */
  92. echo $_SESSION['oLP']->build_action_menu();
  93. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  94. echo '<tr>';
  95. echo '<td class="tree">';
  96. echo '<div class="lp_tree">';
  97. // Build the tree with the menu items in it.
  98. echo $_SESSION['oLP']->build_tree();
  99. echo '</div>';
  100. echo '</td>';
  101. echo '<td class="workspace">';
  102. if (isset($is_success) && $is_success === true) {
  103. echo '<div class="lp_message" style="margin:3px 10px;">';
  104. echo get_lang("PrerequisitesAdded");
  105. echo '</div>';
  106. } else {
  107. echo $_SESSION['oLP']->display_manipulate($_GET['id'], null);
  108. echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']);
  109. }
  110. echo '</td>';
  111. echo '</tr>';
  112. echo '</table>';
  113. /* FOOTER */
  114. Display::display_footer();