lp_move_item.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. /* SHOWING THE ADMIN TOOLS */
  65. if (isset($_SESSION['gradebook'])) {
  66. $gradebook = $_SESSION['gradebook'];
  67. }
  68. if (!empty($gradebook) && $gradebook == 'view') {
  69. $interbreadcrumb[] = array(
  70. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  71. 'name' => get_lang('ToolGradebook')
  72. );
  73. }
  74. $interbreadcrumb[] = array(
  75. 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
  76. 'name' => get_lang('LearningPaths'),
  77. );
  78. $interbreadcrumb[] = array(
  79. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  80. 'name' => stripslashes("{$therow['name']}"),
  81. );
  82. $interbreadcrumb[] = array(
  83. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  84. 'name' => get_lang('NewStep'),
  85. );
  86. // Theme calls
  87. $show_learn_path = true;
  88. $lp_theme_css = $_SESSION['oLP']->get_theme();
  89. Display::display_header(get_lang('Move'), 'Path');
  90. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  91. ?>
  92. <script type='text/javascript'>
  93. /* <![CDATA[ */
  94. function stripslashes(str) {
  95. str=str.replace(/\\'/g,'\'');
  96. str=str.replace(/\\"/g,'"');
  97. str=str.replace(/\\\\/g,'\\');
  98. str=str.replace(/\\0/g,'\0');
  99. return str;
  100. }
  101. function confirmation(name)
  102. {
  103. name=stripslashes(name);
  104. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  105. {
  106. return true;
  107. }
  108. else
  109. {
  110. return false;
  111. }
  112. }
  113. </script>
  114. <?php
  115. echo $_SESSION['oLP']->build_action_menu();
  116. echo '<div class="row">';
  117. echo '<div class="col-md-3">';
  118. echo $_SESSION['oLP']->return_new_tree();
  119. echo '</div>';
  120. echo '<div class="col-md-9">';
  121. if (isset($is_success) && $is_success === true) {
  122. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  123. $msg .= 'The item has been moved.';
  124. $msg .= '</div>';
  125. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  126. } else {
  127. echo $_SESSION['oLP']->display_move_item($_GET['id']);
  128. }
  129. echo '</div>';
  130. echo '</div>';
  131. /* FOOTER */
  132. Display::display_footer();