lp_move_item.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. $learnPath = learnpath::getCurrentLpFromSession();
  15. include 'learnpath_functions.inc.php';
  16. /* Header and action code */
  17. $htmlHeadXtra[] = '<script type="text/javascript">'.
  18. $learnPath->get_js_dropdown_array().
  19. "
  20. function load_cbo(id) {
  21. if (!id) {
  22. return false;
  23. }
  24. var cbo = document.getElementById('previous');
  25. for(var i = cbo.length - 1; i > 0; i--) {
  26. cbo.options[i] = null;
  27. }
  28. var k=0;
  29. for(var i = 1; i <= child_name[id].length; i++) {
  30. cbo.options[i] = new Option(child_name[id][i - 1], child_value[id][i - 1]);
  31. k=i;
  32. }
  33. cbo.options[k].selected = true;
  34. $('#previous').selectpicker('refresh');
  35. }
  36. " .
  37. "\n" .
  38. '$().ready(function() {'."\n" .
  39. 'if ($(\'#previous\')) {'."\n" .
  40. 'if(\'parent is\'+$(\'#idParent\').val()) {'.
  41. 'load_cbo($(\'#idParent\').val());'."\n" .
  42. '}}'."\n" .
  43. '});</script>'."\n" ;
  44. /* Constants and variables */
  45. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  46. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  47. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  48. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  49. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : '';
  50. $learnpath_id = (int) $_REQUEST['lp_id'];
  51. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : '';
  52. /* MAIN CODE */
  53. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  54. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  55. }
  56. // From here on, we are admin because of the previous condition, so don't check anymore.
  57. $course_id = api_get_course_int_id();
  58. $sql = "SELECT * FROM $tbl_lp
  59. WHERE c_id = $course_id AND id = $learnpath_id";
  60. $result = Database::query($sql);
  61. $therow = Database::fetch_array($result);
  62. /*
  63. Course admin section
  64. - all the functions not available for students - always available in this case (page only shown to admin)
  65. */
  66. /* SHOWING THE ADMIN TOOLS */
  67. if (api_is_in_gradebook()) {
  68. $interbreadcrumb[]= array(
  69. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
  70. 'name' => get_lang('ToolGradebook')
  71. );
  72. }
  73. $interbreadcrumb[] = array(
  74. 'url' => 'lp_controller.php?action=list?'.api_get_cidreq(),
  75. 'name' => get_lang('LearningPaths'),
  76. );
  77. $interbreadcrumb[] = array(
  78. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  79. 'name' => stripslashes("{$therow['name']}"),
  80. );
  81. $interbreadcrumb[] = array(
  82. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  83. 'name' => get_lang('NewStep'),
  84. );
  85. // Theme calls
  86. $show_learn_path = true;
  87. $lp_theme_css = $learnPath->get_theme();
  88. Display::display_header(get_lang('Move'), 'Path');
  89. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  90. ?>
  91. <script type='text/javascript'>
  92. /* <![CDATA[ */
  93. function stripslashes(str) {
  94. str=str.replace(/\\'/g,'\'');
  95. str=str.replace(/\\"/g,'"');
  96. str=str.replace(/\\\\/g,'\\');
  97. str=str.replace(/\\0/g,'\0');
  98. return str;
  99. }
  100. function confirmation(name)
  101. {
  102. name=stripslashes(name);
  103. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  104. {
  105. return true;
  106. }
  107. else
  108. {
  109. return false;
  110. }
  111. }
  112. </script>
  113. <?php
  114. echo $learnPath->build_action_menu();
  115. echo '<div class="row">';
  116. echo '<div class="col-md-3">';
  117. echo $learnPath->return_new_tree();
  118. echo '</div>';
  119. echo '<div class="col-md-9">';
  120. if (isset($is_success) && $is_success === true) {
  121. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  122. $msg .= 'The item has been moved.';
  123. $msg .= '</div>';
  124. echo $learnPath->display_item($_GET['id'], $msg);
  125. } else {
  126. echo $learnPath->display_move_item($_GET['id']);
  127. }
  128. echo '</div>';
  129. echo '</div>';