lp_add.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php // $Id: index.php 16620 2008-10-25 20:03:54Z yannoo $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact: Dokeos, rue Notre Dame, 152, B-1140 Evere, Belgium, info@dokeos.com
  15. ==============================================================================
  16. */
  17. /**
  18. ==============================================================================
  19. * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
  20. *
  21. * @author Patrick Cool
  22. * @author Denes Nagy
  23. * @author Roan Embrechts, refactoring and code cleaning
  24. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  25. * @package dokeos.learnpath
  26. ==============================================================================
  27. */
  28. /*
  29. ==============================================================================
  30. INIT SECTION
  31. ==============================================================================
  32. */
  33. $this_section=SECTION_COURSES;
  34. api_protect_course_script();
  35. /*
  36. -----------------------------------------------------------
  37. Libraries
  38. -----------------------------------------------------------
  39. */
  40. //the main_api.lib.php, database.lib.php and display.lib.php
  41. //libraries are included by default
  42. include('learnpath_functions.inc.php');
  43. //include('../resourcelinker/resourcelinker.inc.php');
  44. include('resourcelinker.inc.php');
  45. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  46. // name of the language file that needs to be included
  47. $language_file = 'learnpath';
  48. /*
  49. -----------------------------------------------------------
  50. Header and action code
  51. -----------------------------------------------------------
  52. */
  53. $currentstyle = api_get_setting('stylesheets');
  54. //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'css/'.$currentstyle.'/learnpath.css"/>';
  55. //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="learnpath.css" />'; //will be a merged with original learnpath.css
  56. $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="dtree.css" />'; //will be moved
  57. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  58. $htmlHeadXtra[] = '<script type="text/javascript">
  59. function setFocus(){
  60. $("#learnpath_title").focus();
  61. }
  62. $(document).ready(function () {
  63. setFocus();
  64. });
  65. </script>';
  66. /*
  67. -----------------------------------------------------------
  68. Constants and variables
  69. -----------------------------------------------------------
  70. */
  71. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  72. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  73. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  74. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  75. $isStudentView = (int) $_REQUEST['isStudentView'];
  76. $learnpath_id = (int) $_REQUEST['lp_id'];
  77. $submit = $_POST['submit_button'];
  78. /*
  79. ==============================================================================
  80. MAIN CODE
  81. ==============================================================================
  82. */
  83. // using the resource linker as a tool for adding resources to the learning path
  84. if ($action=="add" and $type=="learnpathitem")
  85. {
  86. $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>";
  87. }
  88. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  89. {
  90. error_log('New LP - User not authorized in lp_add.php');
  91. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  92. }
  93. //from here on, we are admin because of the previous condition, so don't check anymore
  94. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  95. $result=Database::query($sql_query);
  96. $therow=Database::fetch_array($result);
  97. /*
  98. -----------------------------------------------------------
  99. Course admin section
  100. - all the functions not available for students - always available in this case (page only shown to admin)
  101. -----------------------------------------------------------
  102. */
  103. if (isset($_SESSION['gradebook'])){
  104. $gradebook= $_SESSION['gradebook'];
  105. }
  106. if (!empty($gradebook) && $gradebook=='view') {
  107. $interbreadcrumb[]= array (
  108. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  109. 'name' => get_lang('ToolGradebook')
  110. );
  111. }
  112. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  113. $interbreadcrumb[]= array ("url"=>"#", "name"=> get_lang("_add_learnpath"));
  114. Display::display_header(null,'Path');
  115. echo '<div class="actions">';
  116. echo '<a href="lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('scorm.gif',get_lang('ReturnToLearningPaths')).' '.get_lang('ReturnToLearningPaths').'</a>';
  117. echo '</div>';
  118. Display::display_normal_message(get_lang('AddLpIntro'),false);
  119. if ($_POST AND empty($_REQUEST['learnpath_name']))
  120. {
  121. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
  122. }
  123. echo '<form method="post">';
  124. // form title
  125. echo '<div class="row"><div class="form_header">'.get_lang('AddLpToStart').'</div></div>';
  126. // title field
  127. echo '<div class="row">';
  128. echo '<div class="label">';
  129. echo '<label for="idTitle"><span class="form_required">*</span> '.get_lang('LPName').'</label>';
  130. echo '</div>';
  131. echo '<div class="formw">';
  132. echo '<input id="learnpath_title" name="learnpath_name" type="text" size="50" />';
  133. echo '</div>';
  134. echo '</div>';
  135. // submit button
  136. echo '<div class="row">';
  137. echo '<div class="label">';
  138. echo '</div>';
  139. echo '<div class="formw">';
  140. echo '<button class="save" style="width:150px;" type="submit"/>'.get_lang('CreateLearningPath').'</button>';
  141. echo '</div>';
  142. echo '</div>';
  143. echo '<input name="post_time" type="hidden" value="' . time() . '" />';
  144. echo '</form>';
  145. echo '<div class="row">';
  146. echo '<div class="label"></div>';
  147. echo '<div class="formw"><span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small></div>';
  148. echo '</div>';
  149. // footer
  150. Display::display_footer();
  151. ?>