lp_edit_item.php 6.8 KB

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