editpost.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006-2008 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. // name of the language file that needs to be included
  54. $language_file = 'forum';
  55. // including the global dokeos file
  56. require ('../inc/global.inc.php');
  57. // the section (tabs)
  58. $this_section=SECTION_COURSES;
  59. // notice for unauthorized people.
  60. api_protect_course_script(true);
  61. // FCKeditor configuration
  62. $fck_attribute['Width'] = '100%';
  63. $fck_attribute['Height'] = '300';
  64. $fck_attribute['ToolbarSet'] = 'Middle';
  65. $fck_attribute['Config']['IMUploadPath'] = 'upload/forum/';
  66. $fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/';
  67. // including additional library scripts
  68. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  69. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  70. if(!api_is_allowed_to_edit())
  71. {
  72. $fck_attribute['Config']['UserStatus'] = 'student';
  73. }
  74. $nameTools=get_lang('Forum');
  75. /*
  76. -----------------------------------------------------------
  77. Including necessary files
  78. -----------------------------------------------------------
  79. */
  80. include('forumconfig.inc.php');
  81. include('forumfunction.inc.php');
  82. /*
  83. ==============================================================================
  84. MAIN DISPLAY SECTION
  85. ==============================================================================
  86. */
  87. /*
  88. -----------------------------------------------------------
  89. Retrieving forum and forum categorie information
  90. -----------------------------------------------------------
  91. */
  92. // we are getting all the information about the current forum and forum category.
  93. // note pcool: I tried to use only one sql statement (and function) for this
  94. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  95. $current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
  96. $current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum.
  97. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  98. $current_post=get_post_information($_GET['post']);
  99. /*
  100. -----------------------------------------------------------
  101. Header and Breadcrumbs
  102. -----------------------------------------------------------
  103. */
  104. $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
  105. $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
  106. $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title']));
  107. $interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title']));
  108. $interbreadcrumb[]=array("url" => "reply.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => get_lang('EditPost'));
  109. /*
  110. -----------------------------------------------------------
  111. Resource Linker
  112. -----------------------------------------------------------
  113. */
  114. if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources'))
  115. {
  116. $_SESSION['formelements']=$_POST;
  117. $_SESSION['origin']=$_SERVER['REQUEST_URI'];
  118. $_SESSION['breadcrumbs']=$interbreadcrumb;
  119. header("Location: ../resourcelinker/resourcelinker.php");
  120. }
  121. /*
  122. -----------------------------------------------------------
  123. Header
  124. -----------------------------------------------------------
  125. */
  126. Display :: display_header(null);
  127. api_display_tool_title($nameTools);
  128. ////echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
  129. /*
  130. -----------------------------------------------------------
  131. Is the user allowed here?
  132. -----------------------------------------------------------
  133. */
  134. // the user is not allowed here if
  135. // 1. the forumcategory, forum or thread is invisible (visibility==0)
  136. // 2. the forumcategory, forum or thread is locked (locked <>0)
  137. // 3. if anonymous posts are not allowed
  138. // 4. if editing of replies is not allowed
  139. // The only exception is the course manager
  140. // I have split this is several pieces for clarity.
  141. //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)))
  142. if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
  143. {
  144. forum_not_allowed_here();
  145. }
  146. if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
  147. {
  148. forum_not_allowed_here();
  149. }
  150. if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0)
  151. {
  152. forum_not_allowed_here();
  153. }
  154. if (!api_is_allowed_to_edit() AND $current_forum['allow_edit']==0)
  155. {
  156. forum_not_allowed_here();
  157. }
  158. /*
  159. -----------------------------------------------------------
  160. Display Forum Category and the Forum information
  161. -----------------------------------------------------------
  162. */
  163. echo "<table class=\"data_table\" width='100%'>\n";
  164. // the forum category
  165. echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
  166. echo '<a href="viewforum.php?forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />';
  167. echo '<span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';echo "</th>\n";
  168. echo "</th>\n";
  169. echo "\t</tr>\n";
  170. echo '</table>';
  171. // the form for the reply
  172. $values=show_edit_post_form($current_post, $current_thread, $current_forum, $_SESSION['formelements']);
  173. if (!empty($values) and $_POST['SubmitPost'])
  174. {
  175. store_edit_post($values);
  176. }
  177. /*
  178. ==============================================================================
  179. FOOTER
  180. ==============================================================================
  181. */
  182. Display :: display_footer();
  183. ?>