lp_move_item.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. /* INIT SECTION */
  13. $this_section = SECTION_COURSES;
  14. api_protect_course_script();
  15. /* Libraries */
  16. // The main_api.lib.php, database.lib.php and display.lib.php
  17. // libraries are included by default.
  18. include 'learnpath_functions.inc.php';
  19. //include '../resourcelinker/resourcelinker.inc.php';
  20. include 'resourcelinker.inc.php';
  21. // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
  22. // Name of the language file that needs to be included.
  23. $language_file = 'learnpath';
  24. /* Header and action code */
  25. $htmlHeadXtra[] = '<script type="text/javascript">'.
  26. $_SESSION['oLP']->get_js_dropdown_array() .
  27. 'function load_cbo(id){' ."\n" .
  28. 'if (!id) {return false;}'.
  29. 'var cbo = document.getElementById(\'previous\');' .
  30. 'for(var i = cbo.length - 1; i > 0; i--) {' .
  31. 'cbo.options[i] = null;' .
  32. '}' ."\n" .
  33. 'var k=0;' .
  34. 'for(var i = 1; i <= child_name[id].length; i++){' ."\n" .
  35. ' cbo.options[i] = new Option(child_name[id][i-1], child_value[id][i-1]);' ."\n" .
  36. ' k=i;' ."\n" .
  37. '}' ."\n" .
  38. 'cbo.options[k].selected = true;'."\n" .
  39. '}'."\n" .
  40. '$().ready(function() {'."\n" .
  41. 'if ($(\'#previous\')) {'."\n" .
  42. 'if(\'parent is\'+$(\'#idParent\').val()) {'.
  43. 'load_cbo($(\'#idParent\').val());'."\n" .
  44. '}}'."\n" .
  45. '});</script>'."\n" ;
  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 = (int) $_REQUEST['isStudentView'];
  52. $learnpath_id = (int) $_REQUEST['lp_id'];
  53. $submit = $_POST['submit_button'];
  54. /*
  55. $chapter_id = $_GET['chapter_id'];
  56. $title = $_POST['title'];
  57. $description = $_POST['description'];
  58. $Submititem = $_POST['Submititem'];
  59. $action = $_REQUEST['action'];
  60. $id = (int) $_REQUEST['id'];
  61. $type = $_REQUEST['type'];
  62. $direction = $_REQUEST['direction'];
  63. $moduleid = $_REQUEST['moduleid'];
  64. $prereq = $_REQUEST['prereq'];
  65. $type = $_REQUEST['type'];
  66. */
  67. /* MAIN CODE */
  68. // Using the resource linker as a tool for adding resources to the learning path.
  69. if ($action == 'add' && $type == 'learnpathitem') {
  70. $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>";
  71. }
  72. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  73. error_log('New LP - User not authorized in lp_add_item.php');
  74. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  75. }
  76. // From here on, we are admin because of the previous condition, so don't check anymore.
  77. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  78. $result = Database::query($sql_query);
  79. $therow = Database::fetch_array($result);
  80. //$admin_output = '';
  81. /*
  82. Course admin section
  83. - all the functions not available for students - always available in this case (page only shown to admin)
  84. */
  85. /* SHOWING THE ADMIN TOOLS */
  86. if (isset($_SESSION['gradebook'])){
  87. $gradebook= $_SESSION['gradebook'];
  88. }
  89. if (!empty($gradebook) && $gradebook == 'view') {
  90. $interbreadcrumb[] = array (
  91. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  92. 'name' => get_lang('ToolGradebook')
  93. );
  94. }
  95. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  96. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  97. // Theme calls
  98. $show_learn_path = true;
  99. $lp_theme_css = $_SESSION['oLP']->get_theme();
  100. Display::display_header(null, 'Path');
  101. //api_display_tool_title($therow['name']);
  102. $suredel = trim(get_lang('AreYouSureToDelete'));
  103. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  104. ?>
  105. <script type='text/javascript'>
  106. /* <![CDATA[ */
  107. function stripslashes(str) {
  108. str=str.replace(/\\'/g,'\'');
  109. str=str.replace(/\\"/g,'"');
  110. str=str.replace(/\\\\/g,'\\');
  111. str=str.replace(/\\0/g,'\0');
  112. return str;
  113. }
  114. function confirmation(name)
  115. {
  116. name=stripslashes(name);
  117. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  118. {
  119. return true;
  120. }
  121. else
  122. {
  123. return false;
  124. }
  125. }
  126. </script>
  127. <?php
  128. //echo $admin_output;
  129. /* DISPLAY SECTION */
  130. echo $_SESSION['oLP']->build_action_menu();
  131. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  132. echo '<tr>';
  133. echo '<td class="tree">';
  134. echo '<div class="lp_tree">';
  135. // Build the tree with the menu items in it.
  136. echo $_SESSION['oLP']->build_tree();
  137. echo '</div>';
  138. echo '</td>';
  139. echo '<td class="workspace">';
  140. if (isset($is_success) && $is_success === true) {
  141. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  142. $msg .= 'The item has been moved.';
  143. $msg .= '</div>';
  144. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  145. } else {
  146. echo $_SESSION['oLP']->display_move_item($_GET['id']);
  147. }
  148. echo '</td>';
  149. echo '</tr>';
  150. echo '</table>';
  151. /* FOOTER */
  152. Display::display_footer();