editpost.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. // we are getting all the information about the current forum and forum category.
  81. // note pcool: I tried to use only one sql statement (and function) for this
  82. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  83. $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
  84. $current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum.
  85. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  86. $current_post=get_post_information($_GET['post']);
  87. /*
  88. -----------------------------------------------------------
  89. Header and Breadcrumbs
  90. -----------------------------------------------------------
  91. */
  92. $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
  93. $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
  94. $interbreadcrumb[]=array("url" => "viewforum.php?forum=".$_GET['forum'],"name" => prepare4display($current_forum['forum_title']));
  95. $interbreadcrumb[]=array("url" => "viewthread.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title']));
  96. $interbreadcrumb[]=array("url" => "reply.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread'],"name" => get_lang('EditPost'));
  97. /*
  98. -----------------------------------------------------------
  99. Resource Linker
  100. -----------------------------------------------------------
  101. */
  102. if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources'))
  103. {
  104. $_SESSION['formelements']=$_POST;
  105. $_SESSION['origin']=$_SERVER['REQUEST_URI'];
  106. $_SESSION['breadcrumbs']=$interbreadcrumb;
  107. header("Location: ../resourcelinker/resourcelinker.php");
  108. }
  109. /*
  110. -----------------------------------------------------------
  111. Header
  112. -----------------------------------------------------------
  113. */
  114. Display :: display_header();
  115. api_display_tool_title($nameTools);
  116. ////echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
  117. /*
  118. -----------------------------------------------------------
  119. Is the user allowed here?
  120. -----------------------------------------------------------
  121. */
  122. // the user is not allowed here if
  123. // 1. the forumcategory, forum or thread is invisible (visibility==0)
  124. // 2. the forumcategory, forum or thread is locked (locked <>0)
  125. // 3. if anonymous posts are not allowed
  126. // 4. if editing of replies is not allowed
  127. // The only exception is the course manager
  128. // I have split this is several pieces for clarity.
  129. //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)))
  130. if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
  131. {
  132. forum_not_allowed_here();
  133. }
  134. if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
  135. {
  136. forum_not_allowed_here();
  137. }
  138. if (!$_uid AND $current_forum['allow_anonymous']==0)
  139. {
  140. forum_not_allowed_here();
  141. }
  142. if (!api_is_allowed_to_edit() AND $current_forum['allow_edit']==0)
  143. {
  144. forum_not_allowed_here();
  145. }
  146. /*
  147. -----------------------------------------------------------
  148. Display Forum Category and the Forum information
  149. -----------------------------------------------------------
  150. */
  151. echo "<table width='100%'>\n";
  152. // the forum category
  153. echo "\t<tr class=\"forum_category_header\">\n\t\t<td colspan=\"2\">";
  154. echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
  155. echo '<span>'.prepare4display($current_forum_category['cat_comment']).'</span>';
  156. echo "</td>\n";
  157. echo "\t</tr>\n";
  158. // the forum
  159. echo "\t<tr class=\"forum_header\">\n";
  160. echo "\t\t<td colspan=\"2\">";
  161. echo '<a href="viewforum.php?forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />';
  162. echo '<span>'.prepare4display($current_forum['forum_comment']).'</span>';
  163. echo "</td>\n";
  164. echo "\t</tr>\n";
  165. echo '</table>';
  166. // the form for the reply
  167. $values=show_edit_post_form($current_post, $current_thread, $_SESSION['formelements']);
  168. if (!empty($values) and $_POST['SubmitPost'])
  169. {
  170. store_edit_post($values);
  171. }
  172. /*
  173. ==============================================================================
  174. FOOTER
  175. ==============================================================================
  176. */
  177. Display :: display_footer();
  178. ?>