lp_edit_item.php 6.2 KB

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