lp_move_item.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
  25. // Name of the language file that needs to be included.
  26. $language_file = 'learnpath';
  27. /* Header and action code */
  28. $htmlHeadXtra[] = '<script type="text/javascript">'.
  29. $_SESSION['oLP']->get_js_dropdown_array() .
  30. 'function load_cbo(id){' ."\n" .
  31. 'if (!id) {return false;}'.
  32. 'var cbo = document.getElementById(\'previous\');' .
  33. 'for(var i = cbo.length - 1; i > 0; i--) {' .
  34. 'cbo.options[i] = null;' .
  35. '}' ."\n" .
  36. 'var k=0;' .
  37. 'for(var i = 1; i <= child_name[id].length; i++){' ."\n" .
  38. ' cbo.options[i] = new Option(child_name[id][i-1], child_value[id][i-1]);' ."\n" .
  39. ' k=i;' ."\n" .
  40. '}' ."\n" .
  41. 'cbo.options[k].selected = true;'."\n" .
  42. '}'."\n" .
  43. '$().ready(function() {'."\n" .
  44. 'if ($(\'#previous\')) {'."\n" .
  45. 'if(\'parent is\'+$(\'#idParent\').val()) {'.
  46. 'load_cbo($(\'#idParent\').val());'."\n" .
  47. '}}'."\n" .
  48. '});</script>'."\n" ;
  49. /* Constants and variables */
  50. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  51. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  52. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  53. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  54. $isStudentView = (int) $_REQUEST['isStudentView'];
  55. $learnpath_id = (int) $_REQUEST['lp_id'];
  56. $submit = $_POST['submit_button'];
  57. /*
  58. $chapter_id = $_GET['chapter_id'];
  59. $title = $_POST['title'];
  60. $description = $_POST['description'];
  61. $Submititem = $_POST['Submititem'];
  62. $action = $_REQUEST['action'];
  63. $id = (int) $_REQUEST['id'];
  64. $type = $_REQUEST['type'];
  65. $direction = $_REQUEST['direction'];
  66. $moduleid = $_REQUEST['moduleid'];
  67. $prereq = $_REQUEST['prereq'];
  68. $type = $_REQUEST['type'];
  69. */
  70. /* MAIN CODE */
  71. // Using the resource linker as a tool for adding resources to the learning path.
  72. if ($action == 'add' && $type == 'learnpathitem') {
  73. $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>";
  74. }
  75. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  76. error_log('New LP - User not authorized in lp_add_item.php');
  77. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  78. }
  79. // From here on, we are admin because of the previous condition, so don't check anymore.
  80. $course_id = api_get_course_int_id();
  81. $sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  82. $result = Database::query($sql_query);
  83. $therow = Database::fetch_array($result);
  84. //$admin_output = '';
  85. /*
  86. Course admin section
  87. - all the functions not available for students - always available in this case (page only shown to admin)
  88. */
  89. /* SHOWING THE ADMIN TOOLS */
  90. if (isset($_SESSION['gradebook'])){
  91. $gradebook= $_SESSION['gradebook'];
  92. }
  93. if (!empty($gradebook) && $gradebook == 'view') {
  94. $interbreadcrumb[] = array (
  95. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  96. 'name' => get_lang('ToolGradebook')
  97. );
  98. }
  99. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  100. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  101. $interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
  102. // Theme calls
  103. $show_learn_path = true;
  104. $lp_theme_css = $_SESSION['oLP']->get_theme();
  105. Display::display_header(get_lang('Move'), 'Path');
  106. //api_display_tool_title($therow['name']);
  107. $suredel = trim(get_lang('AreYouSureToDelete'));
  108. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  109. ?>
  110. <script type='text/javascript'>
  111. /* <![CDATA[ */
  112. function stripslashes(str) {
  113. str=str.replace(/\\'/g,'\'');
  114. str=str.replace(/\\"/g,'"');
  115. str=str.replace(/\\\\/g,'\\');
  116. str=str.replace(/\\0/g,'\0');
  117. return str;
  118. }
  119. function confirmation(name)
  120. {
  121. name=stripslashes(name);
  122. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  123. {
  124. return true;
  125. }
  126. else
  127. {
  128. return false;
  129. }
  130. }
  131. </script>
  132. <?php
  133. //echo $admin_output;
  134. /* DISPLAY SECTION */
  135. echo $_SESSION['oLP']->build_action_menu();
  136. echo '<div class="row-fluid">';
  137. echo '<div class="span3">';
  138. echo $_SESSION['oLP']->return_new_tree();
  139. echo '</div>';
  140. echo '<div class="span9">';
  141. if (isset($is_success) && $is_success === true) {
  142. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  143. $msg .= 'The item has been moved.';
  144. $msg .= '</div>';
  145. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  146. } else {
  147. echo $_SESSION['oLP']->display_move_item($_GET['id']);
  148. }
  149. echo '</div>';
  150. echo '</div>';
  151. /* FOOTER */
  152. Display::display_footer();