lp_move_item.php 4.0 KB

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