lp_move_item.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php.
  6. *
  7. * @author Patrick Cool
  8. * @author Denes Nagy
  9. * @author Roan Embrechts, refactoring and code cleaning
  10. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  11. *
  12. * @package chamilo.learnpath
  13. */
  14. $this_section = SECTION_COURSES;
  15. api_protect_course_script();
  16. /** @var learnpath $learnPath */
  17. $learnPath = Session::read('oLP');
  18. /* Header and action code */
  19. $htmlHeadXtra[] = '<script>'.
  20. $learnPath->get_js_dropdown_array().
  21. '$().ready(function() {'."\n".
  22. 'if ($(\'#previous\')) {'."\n".
  23. 'if(\'parent is\'+$(\'#idParent\').val()) {'.
  24. 'load_cbo($(\'#idParent\').val());'."\n".
  25. '}}'."\n".
  26. '});</script>';
  27. /* Constants and variables */
  28. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  29. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : '';
  30. $learnpath_id = (int) $_REQUEST['lp_id'];
  31. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : '';
  32. /* MAIN CODE */
  33. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  34. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  35. exit;
  36. }
  37. // From here on, we are admin because of the previous condition, so don't check anymore.
  38. $course_id = api_get_course_int_id();
  39. /*
  40. Course admin section
  41. - all the functions not available for students - always available in this case (page only shown to admin)
  42. */
  43. if (api_is_in_gradebook()) {
  44. $interbreadcrumb[] = [
  45. 'url' => Category::getUrl(),
  46. 'name' => get_lang('ToolGradebook'),
  47. ];
  48. }
  49. $interbreadcrumb[] = [
  50. 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
  51. 'name' => get_lang('LearningPaths'),
  52. ];
  53. $interbreadcrumb[] = [
  54. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  55. 'name' => stripslashes($learnPath->get_name()),
  56. ];
  57. $interbreadcrumb[] = [
  58. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  59. 'name' => get_lang('NewStep'),
  60. ];
  61. // Theme calls
  62. $show_learn_path = true;
  63. $lp_theme_css = $learnPath->get_theme();
  64. Display::display_header(get_lang('Move'), 'Path');
  65. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  66. ?>
  67. <script>
  68. /* <![CDATA[ */
  69. function stripslashes(str) {
  70. str=str.replace(/\\'/g,'\'');
  71. str=str.replace(/\\"/g,'"');
  72. str=str.replace(/\\\\/g,'\\');
  73. str=str.replace(/\\0/g,'\0');
  74. return str;
  75. }
  76. function confirmation(name) {
  77. name=stripslashes(name);
  78. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  79. {
  80. return true;
  81. }
  82. else
  83. {
  84. return false;
  85. }
  86. }
  87. </script>
  88. <?php
  89. echo $learnPath->build_action_menu();
  90. echo '<div class="row">';
  91. echo '<div class="col-md-3">';
  92. echo $learnPath->return_new_tree();
  93. echo '</div>';
  94. echo '<div class="col-md-9">';
  95. if (isset($is_success) && $is_success === true) {
  96. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  97. $msg .= 'The item has been moved.';
  98. $msg .= '</div>';
  99. echo $learnPath->display_item($_GET['id'], $msg);
  100. } else {
  101. echo $learnPath->display_move_item($_GET['id']);
  102. }
  103. echo '</div>';
  104. echo '</div>';
  105. Display::display_footer();