lp_edit_item.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Patrick Cool
  9. Copyright (c) Denes Nagy
  10. Copyright (c) Yannick Warnier
  11. For a full list of contributors, see "credits.txt".
  12. The full license can be read in "license.txt".
  13. This program is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU General Public License
  15. as published by the Free Software Foundation; either version 2
  16. of the License, or (at your option) any later version.
  17. See the GNU General Public License for more details.
  18. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  19. Mail: info@dokeos.com
  20. ==============================================================================
  21. */
  22. /**
  23. ==============================================================================
  24. * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
  25. *
  26. * @author Patrick Cool
  27. * @author Denes Nagy
  28. * @author Roan Embrechts, refactoring and code cleaning
  29. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  30. * @author Julio Montoya - Improving the list of templates
  31. * @package dokeos.learnpath
  32. ==============================================================================
  33. */
  34. /*
  35. ==============================================================================
  36. INIT SECTION
  37. ==============================================================================
  38. */
  39. $this_section=SECTION_COURSES;
  40. api_protect_course_script();
  41. /*
  42. -----------------------------------------------------------
  43. Libraries
  44. -----------------------------------------------------------
  45. */
  46. //the main_api.lib.php, database.lib.php and display.lib.php
  47. //libraries are included by default
  48. include('learnpath_functions.inc.php');
  49. //include('../resourcelinker/resourcelinker.inc.php');
  50. include('resourcelinker.inc.php');
  51. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  52. // name of the language file that needs to be included
  53. $language_file = "learnpath";
  54. /*
  55. -----------------------------------------------------------
  56. Header and action code
  57. -----------------------------------------------------------
  58. */
  59. $htmlHeadXtra[] = '
  60. <script type="text/javascript">
  61. function FCKeditor_OnComplete( editorInstance )
  62. {
  63. document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px; width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
  64. }
  65. function InnerDialogLoaded()
  66. {
  67. if (document.all)
  68. {
  69. // if is iexplorer
  70. var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);
  71. }
  72. else
  73. {
  74. var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
  75. }
  76. return B.ClickFrame();
  77. };
  78. </script>';
  79. $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
  80. /*
  81. -----------------------------------------------------------
  82. Constants and variables
  83. -----------------------------------------------------------
  84. */
  85. $is_allowed_to_edit = api_is_allowed_to_edit();
  86. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  87. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  88. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  89. $isStudentView = (int) $_REQUEST['isStudentView'];
  90. $learnpath_id = (int) $_REQUEST['lp_id'];
  91. $submit = $_POST['submit_button'];
  92. /*
  93. $chapter_id = $_GET['chapter_id'];
  94. $title = $_POST['title'];
  95. $description = $_POST['description'];
  96. $Submititem = $_POST['Submititem'];
  97. $action = $_REQUEST['action'];
  98. $id = (int) $_REQUEST['id'];
  99. $type = $_REQUEST['type'];
  100. $direction = $_REQUEST['direction'];
  101. $moduleid = $_REQUEST['moduleid'];
  102. $prereq = $_REQUEST['prereq'];
  103. $type = $_REQUEST['type'];
  104. */
  105. /*
  106. ==============================================================================
  107. MAIN CODE
  108. ==============================================================================
  109. */
  110. // using the resource linker as a tool for adding resources to the learning path
  111. if ($action=="add" and $type=="learnpathitem")
  112. {
  113. $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>";
  114. }
  115. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  116. {
  117. error_log('New LP - User not authorized in lp_add_item.php');
  118. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  119. }
  120. //from here on, we are admin because of the previous condition, so don't check anymore
  121. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  122. $result=api_sql_query($sql_query);
  123. $therow=Database::fetch_array($result);
  124. //$admin_output = '';
  125. /*
  126. -----------------------------------------------------------
  127. Course admin section
  128. - all the functions not available for students - always available in this case (page only shown to admin)
  129. -----------------------------------------------------------
  130. */
  131. /*==================================================
  132. SHOWING THE ADMIN TOOLS
  133. ==================================================*/
  134. /*==================================================
  135. prerequisites setting end
  136. ==================================================*/
  137. if (isset($_SESSION['gradebook'])){
  138. $gradebook= $_SESSION['gradebook'];
  139. }
  140. if (!empty($gradebook) && $gradebook=='view') {
  141. $interbreadcrumb[]= array (
  142. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  143. 'name' => get_lang('Gradebook')
  144. );
  145. }
  146. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  147. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" =>stripslashes("{$therow['name']}"));
  148. //Theme calls
  149. $show_learn_path=true;
  150. $lp_theme_css=$_SESSION['oLP']->get_theme();
  151. Display::display_header(null,'Path');
  152. //api_display_tool_title($therow['name']);
  153. $suredel = trim(get_lang('AreYouSureToDelete'));
  154. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  155. ?>
  156. <script type='text/javascript'>
  157. /* <![CDATA[ */
  158. function stripslashes(str) {
  159. str=str.replace(/\\'/g,'\'');
  160. str=str.replace(/\\"/g,'"');
  161. str=str.replace(/\\\\/g,'\\');
  162. str=str.replace(/\\0/g,'\0');
  163. return str;
  164. }
  165. function confirmation(name)
  166. {
  167. name=stripslashes(name);
  168. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  169. {
  170. return true;
  171. }
  172. else
  173. {
  174. return false;
  175. }
  176. }
  177. </script>
  178. <?php
  179. //echo $admin_output;
  180. /*
  181. -----------------------------------------------------------
  182. DISPLAY SECTION
  183. -----------------------------------------------------------
  184. */
  185. echo $_SESSION['oLP']->build_action_menu();
  186. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  187. echo '<tr>';
  188. echo '<td class="tree">';
  189. $path_item = isset($_GET['path_item'])?$_GET['path_item']:0;
  190. $path_item = Database::escape_string($path_item);
  191. $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
  192. $sql_doc = "SELECT path FROM " . $tbl_doc . " WHERE id = '". $path_item."' ";
  193. $res_doc=api_sql_query($sql_doc, __FILE__, __LINE__);
  194. $path_file=Database::result($res_doc,0,0);
  195. $path_parts = pathinfo($path_file);
  196. if (Database::num_rows($res_doc) > 0 && $path_parts['extension']=='html'){
  197. $count_items = count($_SESSION['oLP']->ordered_items);
  198. $style = ($count_items > 12)?' style="height:250px;width:230px;overflow-x : auto; overflow : scroll;" ':' class="lp_tree" ';
  199. echo '<div '.$style.'>';
  200. //build the tree with the menu items in it
  201. echo $_SESSION['oLP']->build_tree();
  202. echo '</div>';
  203. // show the template list
  204. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'; //line
  205. echo '<br>';
  206. echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
  207. } else {
  208. echo '<div class="lp_tree" style="height:90%" >';
  209. //build the tree with the menu items in it
  210. echo $_SESSION['oLP']->build_tree();
  211. echo '</div>';
  212. }
  213. echo '</td>';
  214. echo '<td class="workspace">';
  215. if(isset($is_success) && $is_success === true) {
  216. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  217. $msg .= 'The item has been edited.';
  218. $msg .= '</div>';
  219. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  220. } else {
  221. echo $_SESSION['oLP']->display_edit_item($_GET['id']);
  222. }
  223. echo '</td>';
  224. echo '</tr>';
  225. echo '</table>';
  226. /*
  227. ==============================================================================
  228. FOOTER
  229. ==============================================================================
  230. */
  231. Display::display_footer();
  232. ?>