newthread.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006 Dokeos S.A.
  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, 44 rue des palais, 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. /**
  39. **************************************************************************
  40. * IMPORTANT NOTICE
  41. * Please do not change anything is this code yet because there are still
  42. * some significant code that need to happen and I do not have the time to
  43. * merge files and test it all over again. So for the moment, please do not
  44. * touch the code
  45. * -- Patrick Cool <patrick.cool@UGent.be>
  46. **************************************************************************
  47. */
  48. /*
  49. ==============================================================================
  50. INIT SECTION
  51. ==============================================================================
  52. */
  53. /*
  54. -----------------------------------------------------------
  55. Language Initialisation
  56. -----------------------------------------------------------
  57. */
  58. $langFile = 'forum';
  59. require ('../inc/global.inc.php');
  60. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  61. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  62. $nameTools=get_lang('Forum');
  63. /*
  64. -----------------------------------------------------------
  65. Including necessary files
  66. -----------------------------------------------------------
  67. */
  68. include('forumconfig.inc.php');
  69. include('forumfunction.inc.php');
  70. /*
  71. ==============================================================================
  72. MAIN DISPLAY SECTION
  73. ==============================================================================
  74. */
  75. /*
  76. -----------------------------------------------------------
  77. Retrieving forum and forum categorie information
  78. -----------------------------------------------------------
  79. */
  80. $current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum.
  81. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  82. /*
  83. -----------------------------------------------------------
  84. Breadcrumbs
  85. -----------------------------------------------------------
  86. */
  87. $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
  88. $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => $current_forum_category['cat_title']);
  89. $interbreadcrumb[]=array("url" => "viewforum.php?forum=".$_GET['forum'],"name" => $current_forum['forum_title']);
  90. $interbreadcrumb[]=array("url" => "newthread.php?forum=".$_GET['forum'],"name" => get_lang('NewThread'));
  91. /*
  92. -----------------------------------------------------------
  93. Resource Linker
  94. -----------------------------------------------------------
  95. */
  96. if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources'))
  97. {
  98. $_SESSION['formelements']=$_POST;
  99. $_SESSION['origin']=$_SERVER['REQUEST_URI'];
  100. $_SESSION['breadcrumbs']=$interbreadcrumb;
  101. header("Location: ../resourcelinker/resourcelinker.php");
  102. }
  103. /*
  104. -----------------------------------------------------------
  105. Header
  106. -----------------------------------------------------------
  107. */
  108. Display :: display_header($nameTools);
  109. api_display_tool_title($nameTools);
  110. //echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
  111. /*
  112. -----------------------------------------------------------
  113. Is the user allowed here?
  114. -----------------------------------------------------------
  115. */
  116. // the user is not allowed here if:
  117. // 1. the forumcategory or forum is invisible (visibility==0) and the user is not a course manager
  118. // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager
  119. // 3. new threads are not allowed and the user is not a course manager
  120. // 4. anonymous posts are not allowed and the user is not logged in
  121. // I have split this is several pieces for clarity.
  122. if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
  123. {
  124. forum_not_allowed_here();
  125. }
  126. // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager
  127. if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0))
  128. {
  129. forum_not_allowed_here();
  130. }
  131. // 3. new threads are not allowed and the user is not a course manager
  132. if (!api_is_allowed_to_edit() AND $current_forum['allow_new_threads']<>1)
  133. {
  134. forum_not_allowed_here();
  135. }
  136. // 4. anonymous posts are not allowed and the user is not logged in
  137. if (!$_uid AND $current_forum['allow_anonymous']<>1)
  138. {
  139. forum_not_allowed_here();
  140. }
  141. /*
  142. -----------------------------------------------------------
  143. Display forms / Feedback Messages
  144. -----------------------------------------------------------
  145. */
  146. handle_forum_and_forumcategories();
  147. /*
  148. -----------------------------------------------------------
  149. Display Forum Category and the Forum information
  150. -----------------------------------------------------------
  151. */
  152. echo "<table width='100%'>\n";
  153. // the forum category
  154. echo "\t<tr class=\"forum_category\">\n\t\t<td colspan=\"2\">";
  155. echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.$current_forum_category['cat_title'].'</a><br />';
  156. echo '<span>'.$current_forum_category['cat_comment'].'</span>';
  157. echo "</td>\n";
  158. echo "\t</tr>\n";
  159. // the forum
  160. echo "\t<tr class=\"forum_header\">\n";
  161. echo "\t\t<td colspan=\"2\">".$current_forum['forum_title']."<br />";
  162. echo '<span>'.$current_forum['forum_comment'].'</span>';
  163. echo "</td>\n";
  164. echo "\t</tr>\n";
  165. echo '</table>';
  166. $values=show_add_post_form('newthread','', $_SESSION['formelements']);
  167. if (!empty($values) and isset($values['SubmitPost']))
  168. {
  169. store_thread($values);
  170. }
  171. /*
  172. ==============================================================================
  173. FOOTER
  174. ==============================================================================
  175. */
  176. Display :: display_footer();
  177. ?>