reply.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006-2008 Dokeos SPRL
  6. Copyright (c) 2006 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 address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
  15. Mail: info@dokeos.com
  16. ==============================================================================
  17. */
  18. /**
  19. * These files are a complete rework of the forum. The database structure is
  20. * based on phpBB but all the code is rewritten. A lot of new functionalities
  21. * are added:
  22. * - forum categories and forums can be sorted up or down, locked or made invisible
  23. * - consistent and integrated forum administration
  24. * - forum options: are students allowed to edit their post?
  25. * moderation of posts (approval)
  26. * reply only forums (students cannot create new threads)
  27. * multiple forums per group
  28. * - sticky messages
  29. * - new view option: nested view
  30. * - quoting a message
  31. *
  32. * @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  33. * @Copyright Ghent University
  34. * @Copyright Patrick Cool
  35. *
  36. * @package dokeos.forum
  37. */
  38. // name of the language file that needs to be included
  39. $language_file = array('forum','document');
  40. // including the global dokeos file
  41. require '../inc/global.inc.php';
  42. // the section (tabs)
  43. $this_section=SECTION_COURSES;
  44. // notice for unauthorized people.
  45. api_protect_course_script(true);
  46. // configuration for FCKeditor
  47. $fck_attribute['Width'] = '100%';
  48. $fck_attribute['Height'] = '400';
  49. if(!api_is_allowed_to_edit(false,true)) {
  50. $fck_attribute['Config']['UserStatus'] = 'student';
  51. $fck_attribute['ToolbarSet'] = 'Forum_Student';
  52. }
  53. else
  54. {
  55. $fck_attribute['ToolbarSet'] = 'Forum';
  56. }
  57. // including additional library scripts
  58. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  59. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  60. $nameTools=get_lang('Forum');
  61. $origin = '';
  62. if(isset($_GET['origin'])) {
  63. $origin = Security::remove_XSS($_GET['origin']);
  64. $origin_string = '&origin='.$origin;
  65. }
  66. /*
  67. -----------------------------------------------------------
  68. Including necessary files
  69. -----------------------------------------------------------
  70. */
  71. require 'forumconfig.inc.php';
  72. require_once 'forumfunction.inc.php';
  73. // javascript
  74. $htmlHeadXtra[] = '<script>
  75. function advanced_parameters() {
  76. if(document.getElementById(\'id_qualify\').style.display == \'none\') {
  77. document.getElementById(\'id_qualify\').style.display = \'block\';
  78. document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img src="../img/div_hide.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  79. } else {
  80. document.getElementById(\'id_qualify\').style.display = \'none\';
  81. document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  82. }
  83. }
  84. </script>';
  85. /*
  86. ==============================================================================
  87. MAIN DISPLAY SECTION
  88. ==============================================================================
  89. */
  90. /*
  91. -----------------------------------------------------------
  92. Retrieving forum and forum categorie information
  93. -----------------------------------------------------------
  94. */
  95. // we are getting all the information about the current forum and forum category.
  96. // note pcool: I tried to use only one sql statement (and function) for this
  97. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  98. $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
  99. $current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
  100. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  101. /*
  102. -----------------------------------------------------------
  103. Breadcrumbs
  104. -----------------------------------------------------------
  105. */
  106. if (isset($_SESSION['gradebook'])){
  107. $gradebook= $_SESSION['gradebook'];
  108. }
  109. if (!empty($gradebook) && $gradebook=='view') {
  110. $interbreadcrumb[]= array (
  111. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  112. 'name' => get_lang('Gradebook')
  113. );
  114. }
  115. if (!empty($_SESSION['toolgroup'])) {
  116. $_clean['toolgroup']=(int)$_SESSION['toolgroup'];
  117. $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
  118. $interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
  119. $interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')');
  120. $interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']);
  121. $interbreadcrumb[]=array("url" => "viewthread.php?origin=".$origin."&gradebook=".$gradebook."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => $current_thread['thread_title']);
  122. $interbreadcrumb[]=array("url" => "#","name" => get_lang('Reply'));
  123. } else {
  124. $interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook","name" => $nameTools);
  125. $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => $current_forum_category['cat_title']);
  126. $interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']);
  127. $interbreadcrumb[]=array("url" => "viewthread.php?origin=".$origin."&gradebook=".$gradebook."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => $current_thread['thread_title']);
  128. $interbreadcrumb[]=array("url" => "#","name" => get_lang('Reply'));
  129. }
  130. /*
  131. -----------------------------------------------------------
  132. Resource Linker
  133. -----------------------------------------------------------
  134. */
  135. if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
  136. $_SESSION['formelements']=$_POST;
  137. $_SESSION['origin']=$_SERVER['REQUEST_URI'];
  138. $_SESSION['breadcrumbs']=$interbreadcrumb;
  139. header("Location: ../resourcelinker/resourcelinker.php");
  140. }
  141. /*
  142. -----------------------------------------------------------
  143. Header
  144. -----------------------------------------------------------
  145. */
  146. if($origin=='learnpath') {
  147. include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
  148. } else {
  149. // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
  150. Display :: display_header('');
  151. api_display_tool_title($nameTools);
  152. }
  153. /*
  154. -----------------------------------------------------------
  155. Is the user allowed here?
  156. -----------------------------------------------------------
  157. */
  158. // The user is not allowed here if
  159. // 1. the forumcategory, forum or thread is invisible (visibility==0
  160. // 2. the forumcategory, forum or thread is locked (locked <>0)
  161. // 3. if anonymous posts are not allowed
  162. // The only exception is the course manager
  163. // I have split this is several pieces for clarity.
  164. //if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)))
  165. if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) {
  166. forum_not_allowed_here();
  167. }
  168. if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)) {
  169. forum_not_allowed_here();
  170. }
  171. if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) {
  172. forum_not_allowed_here();
  173. }
  174. /*
  175. -----------------------------------------------------------
  176. Action links
  177. -----------------------------------------------------------
  178. */
  179. echo '<div class="actions">';
  180. echo '<span style="float:right;">'.search_link().'</span>';
  181. echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png').' '.get_lang('BackToForumOverview').'</a>';
  182. echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'">'.Display::return_icon('forum.gif').' '.get_lang('BackToForum').'</a>';
  183. echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'">'.Display::return_icon('forumthread.gif').' '.get_lang('BackToThread').'</a>';
  184. echo '</div>';
  185. /*
  186. -----------------------------------------------------------
  187. Display Forum Category and the Forum information
  188. -----------------------------------------------------------
  189. */
  190. echo "<table class=\"data_table\" width='100%'>\n";
  191. // the forum category
  192. echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
  193. echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
  194. if (!empty ($current_forum_category['cat_title'])) {
  195. echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])." - </span>";
  196. }
  197. echo '<span class="forum_low_description">'.prepare4display($current_forum['forum_title']).'</span>';
  198. echo "</th>\n";
  199. echo "\t</tr>\n";
  200. echo '</table>';
  201. // the form for the reply
  202. $my_action = isset($_GET['action']) ? $_GET['action'] : '';
  203. $my_post = isset($_GET['post']) ? $_GET['post'] : '';
  204. $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '';
  205. $values=show_add_post_form($my_action,$my_post, $my_elements); // note: this has to be cleaned first
  206. if (!empty($values) AND isset($_POST['SubmitPost'])) {
  207. store_reply($values);
  208. }
  209. /*
  210. ==============================================================================
  211. FOOTER
  212. ==============================================================================
  213. */
  214. if($origin!='learnpath') {
  215. Display :: display_footer();
  216. }