viewthread.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. //require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php');
  63. $nameTools=get_lang('Forum');
  64. /*
  65. -----------------------------------------------------------
  66. Including necessary files
  67. -----------------------------------------------------------
  68. */
  69. include('forumconfig.inc.php');
  70. include('forumfunction.inc.php');
  71. /*
  72. ==============================================================================
  73. MAIN DISPLAY SECTION
  74. ==============================================================================
  75. */
  76. /*
  77. -----------------------------------------------------------
  78. Retrieving forum and forum categorie information
  79. -----------------------------------------------------------
  80. */
  81. // we are getting all the information about the current forum and forum category.
  82. // note pcool: I tried to use only one sql statement (and function) for this
  83. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  84. $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
  85. $current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
  86. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  87. $whatsnew_post_info=$_SESSION['whatsnew_post_info'];
  88. /*
  89. -----------------------------------------------------------
  90. Header and Breadcrumbs
  91. -----------------------------------------------------------
  92. */
  93. $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
  94. $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
  95. $interbreadcrumb[]=array("url" => "viewforum.php?forum=".$_GET['forum'],"name" => prepare4display($current_forum['forum_title']));
  96. if ($message<>'PostDeletedSpecial')
  97. {
  98. $interbreadcrumb[]=array("url" => "viewthread.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title']));
  99. }
  100. Display :: display_header();
  101. api_display_tool_title($nameTools);
  102. //echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
  103. /*
  104. -----------------------------------------------------------
  105. Is the user allowed here?
  106. -----------------------------------------------------------
  107. */
  108. // if the user is not a course administrator and the forum is hidden
  109. // then the user is not allowed here.
  110. if (!api_is_allowed_to_edit() AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0))
  111. {
  112. forum_not_allowed_here();
  113. }
  114. /*
  115. -----------------------------------------------------------
  116. Actions
  117. -----------------------------------------------------------
  118. */
  119. if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
  120. {
  121. $message=delete_post($_GET['id']); // note: this has to be cleaned first
  122. }
  123. if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['id']) AND api_is_allowed_to_edit())
  124. {
  125. $message=approve_post($_GET['id'],$_GET['action']); // note: this has to be cleaned first
  126. }
  127. if ($_GET['action']=='move' and isset($_GET['post']))
  128. {
  129. $message=move_post_form();
  130. }
  131. /*
  132. -----------------------------------------------------------
  133. Display the action messages
  134. -----------------------------------------------------------
  135. */
  136. if (isset($message))
  137. {
  138. Display :: display_normal_message(get_lang($message));
  139. }
  140. if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
  141. {
  142. // this increases the number of times the thread has been viewed
  143. increase_thread_view($_GET['thread']);
  144. /*
  145. -----------------------------------------------------------
  146. Action Links
  147. -----------------------------------------------------------
  148. */
  149. echo '<div style="float:right;">';
  150. echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=flat">'.get_lang('FlatView').'</a> | ';
  151. echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=threaded">'.get_lang('ThreadedView').'</a> | ';
  152. echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=nested">'.get_lang('NestedView').'</a>';
  153. echo '</div>';
  154. // the reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
  155. // if one of the three levels is locked then the link should not be displayed
  156. if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit())
  157. {
  158. // The link should only appear when the user is logged in or when anonymous posts are allowed.
  159. if ($_uid OR ($current_forum['allow_anonymous']==1 AND !$_uid))
  160. {
  161. echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;action=replythread">'.get_lang('ReplyToThread').'</a>';
  162. }
  163. }
  164. // note: this is to prevent that some browsers display the links over the table (FF does it but Opera doesn't)
  165. echo '&nbsp;';
  166. /*
  167. -----------------------------------------------------------
  168. Display Forum Category and the Forum information
  169. -----------------------------------------------------------
  170. */
  171. if (!$_SESSION['view'])
  172. {
  173. $viewmode=$current_forum['default_view'];
  174. }
  175. else
  176. {
  177. $viewmode=$_SESSION['view'];
  178. }
  179. $viewmode_whitelist=array('flat', 'threaded', 'nested');
  180. if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist))
  181. {
  182. $viewmode=$_GET['view'];
  183. $_SESSION['view']=$viewmode;
  184. }
  185. /*
  186. -----------------------------------------------------------
  187. Display Forum Category and the Forum information
  188. -----------------------------------------------------------
  189. */
  190. // we are getting all the information about the current forum and forum category.
  191. // note pcool: I tried to use only one sql statement (and function) for this
  192. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  193. echo "<table width='100%'>\n";
  194. // the forum category
  195. echo "\t<tr class=\"forum_category\">\n\t\t<td colspan=\"6\">";
  196. echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
  197. echo '<span>'.prepare4display($current_forum_category['cat_comment']).'</span>';
  198. echo "</td>\n";
  199. echo "\t</tr>\n";
  200. // the forum
  201. echo "\t<tr class=\"forum_header\">\n";
  202. echo "\t\t<td><a href=\"viewforum.php?forum=".$current_forum['forum_id']."\" ".class_visible_invisible($current_forum['visibility']).">".prepare4display($current_forum['forum_title'])."</a><br />";
  203. echo '<span>'.prepare4display($current_forum['forum_comment']).'</span>';
  204. echo "</td>\n";
  205. echo "\t</tr>\n";
  206. // the thread
  207. echo "\t<tr class=\"forum_thread\">\n";
  208. echo "\t\t<td><span ".class_visible_invisible($current_thread['visibility']).">".prepare4display($current_thread['thread_title'])."</span><br />";
  209. echo "</td>\n";
  210. echo "\t</tr>\n";
  211. echo "</table>";
  212. echo '<br />';
  213. switch ($viewmode)
  214. {
  215. case 'flat':
  216. include_once('viewthread_flat.inc.php');
  217. break;
  218. case 'threaded':
  219. include_once('viewthread_threaded.inc.php');
  220. break;
  221. case 'nested':
  222. include_once('viewthread_nested.inc.php');
  223. break;
  224. }
  225. } // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
  226. /*
  227. ==============================================================================
  228. FOOTER
  229. ==============================================================================
  230. */
  231. Display :: display_footer();
  232. ?>