lp_edit_item.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. * @author Julio Montoya - Improving the list of templates
  11. * @package chamilo.learnpath
  12. */
  13. /**
  14. * INIT SECTION
  15. */
  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[] = '
  29. <script type="text/javascript">
  30. function FCKeditor_OnComplete( editorInstance ) {
  31. document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px; width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
  32. }
  33. function InnerDialogLoaded() {
  34. if (document.all) {
  35. // if is iexplorer
  36. var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);
  37. } else {
  38. var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
  39. }
  40. return B.ClickFrame();
  41. $};'.$_SESSION['oLP']->get_js_dropdown_array().'</script>';
  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 = (int) $_REQUEST['isStudentView'];
  48. $learnpath_id = (int) $_REQUEST['lp_id'];
  49. $submit = $_POST['submit_button'];
  50. /* MAIN CODE */
  51. // Using the resource linker as a tool for adding resources to the learning path.
  52. if ($action == 'add' && $type == 'learnpathitem') {
  53. $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>";
  54. }
  55. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  56. error_log('New LP - User not authorized in lp_add_item.php');
  57. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  58. }
  59. // From here on, we are admin because of the previous condition, so don't check anymore.
  60. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  61. $result = Database::query($sql_query);
  62. $therow = Database::fetch_array($result);
  63. /*
  64. Course admin section
  65. - all the functions not available for students - always available in this case (page only shown to admin)
  66. */
  67. /* SHOWING THE ADMIN TOOLS */
  68. if (isset($_SESSION['gradebook'])) {
  69. $gradebook = $_SESSION['gradebook'];
  70. }
  71. if (!empty($gradebook) && $gradebook == 'view') {
  72. $interbreadcrumb[] = array (
  73. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  74. 'name' => get_lang('ToolGradebook')
  75. );
  76. }
  77. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  78. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  79. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
  80. // Theme calls.
  81. $show_learn_path = true;
  82. $lp_theme_css = $_SESSION['oLP']->get_theme();
  83. Display::display_header(null,'Path');
  84. $suredel = trim(get_lang('AreYouSureToDelete'));
  85. ?>
  86. <script type='text/javascript'>
  87. /* <![CDATA[ */
  88. function stripslashes(str) {
  89. str=str.replace(/\\'/g,'\'');
  90. str=str.replace(/\\"/g,'"');
  91. str=str.replace(/\\\\/g,'\\');
  92. str=str.replace(/\\0/g,'\0');
  93. return str;
  94. }
  95. function confirmation(name) {
  96. name=stripslashes(name);
  97. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  98. return true;
  99. } else {
  100. return false;
  101. }
  102. }
  103. </script>
  104. <?php
  105. /* DISPLAY SECTION */
  106. echo $_SESSION['oLP']->build_action_menu();
  107. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  108. echo '<tr>';
  109. echo '<td class="tree">';
  110. $path_item = isset($_GET['path_item']) ? $_GET['path_item'] : 0;
  111. $path_item = Database::escape_string($path_item);
  112. $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
  113. $sql_doc = "SELECT path FROM " . $tbl_doc . " WHERE id = '". $path_item."' ";
  114. $res_doc = Database::query($sql_doc);
  115. $path_file = Database::result($res_doc, 0, 0);
  116. $path_parts = pathinfo($path_file);
  117. if (Database::num_rows($res_doc) > 0 && $path_parts['extension'] == 'html') {
  118. $count_items = count($_SESSION['oLP']->ordered_items);
  119. $style = ($count_items > 12) ? ' style="height:250px;width:230px;overflow-x : auto; overflow : scroll;" ' : ' class="lp_tree" ';
  120. echo '<div '.$style.'>';
  121. // Build the tree with the menu items in it.
  122. echo $_SESSION['oLP']->build_tree();
  123. echo '</div>';
  124. // Show the template list
  125. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>';
  126. echo '<br />';
  127. echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
  128. } else {
  129. echo '<div class="lp_tree" style="height:90%" >';
  130. // Build the tree with the menu items in it.
  131. echo $_SESSION['oLP']->build_tree();
  132. echo '</div>';
  133. }
  134. echo '</td>';
  135. echo '<td class="workspace">';
  136. if (isset($is_success) && $is_success === true) {
  137. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  138. $msg .= 'The item has been edited.';
  139. $msg .= '</div>';
  140. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  141. } else {
  142. echo $_SESSION['oLP']->display_edit_item($_GET['id']);
  143. }
  144. echo '</td>';
  145. echo '</tr>';
  146. echo '</table>';
  147. /* FOOTER */
  148. Display::display_footer();