lp_edit_item.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. 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>
  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().'
  40. </script>';
  41. /* Constants and variables */
  42. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  43. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  44. $isStudentView = (int) $_REQUEST['isStudentView'];
  45. $learnpath_id = (int) $_REQUEST['lp_id'];
  46. $submit = $_POST['submit_button'];
  47. /* MAIN CODE */
  48. // Using the resource linker as a tool for adding resources to the learning path.
  49. if ($action == 'add' && $type == 'learnpathitem') {
  50. $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>";
  51. }
  52. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  53. error_log('New LP - User not authorized in lp_add_item.php');
  54. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  55. }
  56. // From here on, we are admin because of the previous condition, so don't check anymore.
  57. $course_id = api_get_course_int_id();
  58. $sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND 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. $interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
  78. // Theme calls.
  79. $show_learn_path = true;
  80. $lp_theme_css = $_SESSION['oLP']->get_theme();
  81. Display::display_header(get_lang('Edit'),'Path');
  82. $suredel = trim(get_lang('AreYouSureToDelete'));
  83. ?>
  84. <script>
  85. /* <![CDATA[ */
  86. function stripslashes(str) {
  87. str=str.replace(/\\'/g,'\'');
  88. str=str.replace(/\\"/g,'"');
  89. str=str.replace(/\\\\/g,'\\');
  90. str=str.replace(/\\0/g,'\0');
  91. return str;
  92. }
  93. function confirmation(name) {
  94. name=stripslashes(name);
  95. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  96. return true;
  97. } else {
  98. return false;
  99. }
  100. }
  101. </script>
  102. <?php
  103. /* DISPLAY SECTION */
  104. echo $_SESSION['oLP']->build_action_menu();
  105. echo '<div class="row-fluid">';
  106. echo '<div class="span3">';
  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 c_id = $course_id AND 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. echo $_SESSION['oLP']->return_new_tree();
  116. // Show the template list
  117. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>';
  118. echo '<br />';
  119. echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
  120. } else {
  121. echo $_SESSION['oLP']->return_new_tree();
  122. }
  123. echo '</div>';
  124. echo '<div class="span9">';
  125. if (isset($is_success) && $is_success === true) {
  126. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  127. $msg .= 'The item has been edited.';
  128. $msg .= '</div>';
  129. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  130. } else {
  131. echo $_SESSION['oLP']->display_edit_item($_GET['id']);
  132. }
  133. echo '</div>';
  134. echo '</div>';
  135. /* FOOTER */
  136. Display::display_footer();