editpost.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. // name of the language file that needs to be included
  59. $language_file = 'forum';
  60. require ('../inc/global.inc.php');
  61. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  62. include_once (api_get_path(LIBRARY_PATH).'groupmanager.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($_GET['forum']); // note: this has to be validated that it is an existing forum.
  86. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  87. $current_post=get_post_information($_GET['post']);
  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. $interbreadcrumb[]=array("url" => "viewthread.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title']));
  97. $interbreadcrumb[]=array("url" => "reply.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread'],"name" => get_lang('EditPost'));
  98. /*
  99. -----------------------------------------------------------
  100. Resource Linker
  101. -----------------------------------------------------------
  102. */
  103. if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources'))
  104. {
  105. $_SESSION['formelements']=$_POST;
  106. $_SESSION['origin']=$_SERVER['REQUEST_URI'];
  107. $_SESSION['breadcrumbs']=$interbreadcrumb;
  108. header("Location: ../resourcelinker/resourcelinker.php");
  109. }
  110. /*
  111. -----------------------------------------------------------
  112. Header
  113. -----------------------------------------------------------
  114. */
  115. Display :: display_header();
  116. api_display_tool_title($nameTools);
  117. ////echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
  118. /*
  119. -----------------------------------------------------------
  120. Is the user allowed here?
  121. -----------------------------------------------------------
  122. */
  123. // the user is not allowed here if
  124. // 1. the forumcategory, forum or thread is invisible (visibility==0)
  125. // 2. the forumcategory, forum or thread is locked (locked <>0)
  126. // 3. if anonymous posts are not allowed
  127. // 4. if editing of replies is not allowed
  128. // The only exception is the course manager
  129. // I have split this is several pieces for clarity.
  130. //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)))
  131. if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
  132. {
  133. forum_not_allowed_here();
  134. }
  135. if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
  136. {
  137. forum_not_allowed_here();
  138. }
  139. if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0)
  140. {
  141. forum_not_allowed_here();
  142. }
  143. if (!api_is_allowed_to_edit() AND $current_forum['allow_edit']==0)
  144. {
  145. forum_not_allowed_here();
  146. }
  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_header\">\n\t\t<td colspan=\"2\">";
  155. echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
  156. echo '<span>'.prepare4display($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\">";
  162. echo '<a href="viewforum.php?forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />';
  163. echo '<span>'.prepare4display($current_forum['forum_comment']).'</span>';
  164. echo "</td>\n";
  165. echo "\t</tr>\n";
  166. echo '</table>';
  167. // the form for the reply
  168. $values=show_edit_post_form($current_post, $current_thread, $_SESSION['formelements']);
  169. if (!empty($values) and $_POST['SubmitPost'])
  170. {
  171. store_edit_post($values);
  172. }
  173. /*
  174. ==============================================================================
  175. FOOTER
  176. ==============================================================================
  177. */
  178. Display :: display_footer();
  179. ?>