lp_move_item.php 5.3 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. /**
  13. * Code
  14. */
  15. /* INIT SECTION */
  16. $this_section = SECTION_COURSES;
  17. api_protect_course_script();
  18. /* Libraries */
  19. // The main_api.lib.php, database.lib.php and display.lib.php
  20. // libraries are included by default.
  21. include 'learnpath_functions.inc.php';
  22. //include '../resourcelinker/resourcelinker.inc.php';
  23. include 'resourcelinker.inc.php';
  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. $course_id = api_get_course_int_id();
  78. $sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  79. $result = Database::query($sql_query);
  80. $therow = Database::fetch_array($result);
  81. //$admin_output = '';
  82. /*
  83. Course admin section
  84. - all the functions not available for students - always available in this case (page only shown to admin)
  85. */
  86. /* SHOWING THE ADMIN TOOLS */
  87. if (isset($_SESSION['gradebook'])){
  88. $gradebook= $_SESSION['gradebook'];
  89. }
  90. if (!empty($gradebook) && $gradebook == 'view') {
  91. $interbreadcrumb[] = array (
  92. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  93. 'name' => get_lang('ToolGradebook')
  94. );
  95. }
  96. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  97. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  98. $interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
  99. // Theme calls
  100. $show_learn_path = true;
  101. $lp_theme_css = $_SESSION['oLP']->get_theme();
  102. Display::display_header(get_lang('Move'), 'Path');
  103. //api_display_tool_title($therow['name']);
  104. $suredel = trim(get_lang('AreYouSureToDelete'));
  105. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  106. ?>
  107. <script type='text/javascript'>
  108. /* <![CDATA[ */
  109. function stripslashes(str) {
  110. str=str.replace(/\\'/g,'\'');
  111. str=str.replace(/\\"/g,'"');
  112. str=str.replace(/\\\\/g,'\\');
  113. str=str.replace(/\\0/g,'\0');
  114. return str;
  115. }
  116. function confirmation(name)
  117. {
  118. name=stripslashes(name);
  119. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  120. {
  121. return true;
  122. }
  123. else
  124. {
  125. return false;
  126. }
  127. }
  128. </script>
  129. <?php
  130. //echo $admin_output;
  131. /* DISPLAY SECTION */
  132. echo $_SESSION['oLP']->build_action_menu();
  133. echo '<div class="row">';
  134. echo '<div class="col-md-3">';
  135. echo $_SESSION['oLP']->return_new_tree();
  136. echo '</div>';
  137. echo '<div class="col-md-9">';
  138. if (isset($is_success) && $is_success === true) {
  139. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  140. $msg .= 'The item has been moved.';
  141. $msg .= '</div>';
  142. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  143. } else {
  144. echo $_SESSION['oLP']->display_move_item($_GET['id']);
  145. }
  146. echo '</div>';
  147. echo '</div>';
  148. /* FOOTER */
  149. Display::display_footer();