dokeos-forum
[ class tree: dokeos-forum ] [ index: dokeos-forum ] [ all elements ]

Source for file newthread.php

Documentation is available at newthread.php

  1. <?php
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2006-2008 Dokeos S.A.
  7.     Copyright (c) 2006 Ghent University (UGent)
  8.  
  9.     For a full list of contributors, see "credits.txt".
  10.     The full license can be read in "license.txt".
  11.  
  12.     This program is free software; you can redistribute it and/or
  13.     modify it under the terms of the GNU General Public License
  14.     as published by the Free Software Foundation; either version 2
  15.     of the License, or (at your option) any later version.
  16.  
  17.     See the GNU General Public License for more details.
  18.  
  19.     Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  20.     Mail: info@dokeos.com
  21. ==============================================================================
  22. */
  23.  
  24. /**
  25. *    These files are a complete rework of the forum. The database structure is
  26. *    based on phpBB but all the code is rewritten. A lot of new functionalities
  27. *    are added:
  28. *     - forum categories and forums can be sorted up or down, locked or made invisible
  29. *    - consistent and integrated forum administration
  30. *     - forum options:     are students allowed to edit their post?
  31. *                         moderation of posts (approval)
  32. *                         reply only forums (students cannot create new threads)
  33. *                         multiple forums per group
  34. *    - sticky messages
  35. *     - new view option: nested view
  36. *     - quoting a message
  37. *
  38. *    @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  39. *    @Copyright Ghent University
  40. *    @Copyright Patrick Cool
  41. *
  42. *     @package dokeos.forum
  43. */
  44.  
  45. // name of the language file that needs to be included
  46. $language_file array('forum','document');
  47.  
  48. // including the global dokeos file
  49. require ('../inc/global.inc.php');
  50.  
  51. // the section (tabs)
  52. $this_section=SECTION_COURSES;
  53.  
  54. // notice for unauthorized people.
  55.  
  56. // including additional library scripts
  57. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  58. include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
  59. $nameTools=get_lang('Forum');
  60.  
  61. // configuration for FCKeditor
  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. {
  68.     $fck_attribute['Config']['UserStatus''student';
  69. }
  70. /*
  71. -----------------------------------------------------------
  72.     Including necessary files
  73. -----------------------------------------------------------
  74. */
  75. include('forumconfig.inc.php');
  76. include('forumfunction.inc.php');
  77.  
  78.  
  79. //are we in a lp ?
  80. $origin '';
  81. if(isset($_GET['origin']))
  82. {
  83.     $origin =  Security::remove_XSS($_GET['origin']);
  84. }
  85.  
  86.  
  87. /*
  88. ==============================================================================
  89.         MAIN DISPLAY SECTION
  90. ==============================================================================
  91. */
  92. /*
  93. -----------------------------------------------------------
  94.     Retrieving forum and forum categorie information
  95. -----------------------------------------------------------
  96. */
  97. $current_forum=get_forum_information($_GET['forum'])// note: this has to be validated that it is an existing forum.
  98. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  99.  
  100. /*
  101. -----------------------------------------------------------
  102.     Breadcrumbs
  103. -----------------------------------------------------------
  104. */
  105. $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
  106. $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => $current_forum_category['cat_title']);
  107. $interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']);
  108. $interbreadcrumb[]=array("url" => "newthread.php?forum=".Security::remove_XSS($_GET['forum']),"name" => get_lang('NewTopic'));
  109.  
  110. /*
  111. -----------------------------------------------------------
  112.     Resource Linker
  113. -----------------------------------------------------------
  114. */
  115. if (isset($_POST['add_resources']AND $_POST['add_resources']==get_lang('Resources'))
  116. {
  117.     $_SESSION['formelements']=$_POST;
  118.     $_SESSION['origin']=$_SERVER['REQUEST_URI'];
  119.     $_SESSION['breadcrumbs']=$interbreadcrumb;
  120.     header("Location: ../resourcelinker/resourcelinker.php");
  121. }
  122.  
  123. /*
  124. -----------------------------------------------------------
  125.     Header
  126. -----------------------------------------------------------
  127. */
  128. if($origin=='learnpath')
  129. {
  130.     include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
  131. else
  132. {
  133.     Display :: display_header(null);
  134.     api_display_tool_title($nameTools);
  135. }
  136. //echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
  137. /*
  138. -----------------------------------------------------------
  139.     Is the user allowed here?
  140. -----------------------------------------------------------
  141. */
  142. // the user is not allowed here if:
  143. // 1. the forumcategory or forum is invisible (visibility==0) and the user is not a course manager
  144. // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager
  145. // 3. new threads are not allowed and the user is not a course manager
  146. // 4. anonymous posts are not allowed and the user is not logged in
  147. // I have split this is several pieces for clarity.
  148.  
  149. if (!api_is_allowed_to_edit(AND (($current_forum_category['visibility']==OR $current_forum['visibility']==0)))
  150. {
  151. }
  152. // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager
  153. if (!api_is_allowed_to_edit(AND ($current_forum_category['locked']<>OR $current_forum['locked']<>0))
  154. {
  155. }
  156. // 3. new threads are not allowed and the user is not a course manager
  157. if (!api_is_allowed_to_edit(AND $current_forum['allow_new_threads']<>1)
  158. {
  159. }
  160. // 4. anonymous posts are not allowed and the user is not logged in
  161. if (!$_user['user_id']  AND $current_forum['allow_anonymous']<>1)
  162. {
  163. }
  164.  
  165. /*
  166. -----------------------------------------------------------
  167.     Display forms / Feedback Messages
  168. -----------------------------------------------------------
  169. */
  170.  
  171. /*
  172. -----------------------------------------------------------
  173.     Display Forum Category and the Forum information
  174. -----------------------------------------------------------
  175. */
  176. echo "<table class=\"data_table\" width='100%'>\n";
  177.  
  178. if($origin != 'learnpath')
  179. {
  180.     echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\"  colspan=\"2\">";
  181.     
  182.     echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>';
  183.         
  184.     if (!empty ($current_forum['forum_comment'])) 
  185.     {
  186.         echo '<br><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';
  187.     }
  188.     
  189.     if (!empty ($current_forum_category['cat_title'])) 
  190.     {
  191.         echo '<br /><span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />";
  192.     }    
  193.     echo "</th>\n";
  194.     echo "\t</tr>\n";
  195. }
  196. echo '</table>';
  197.  
  198. $values=show_add_post_form('newthread',''$_SESSION['formelements']);
  199. if (!empty($valuesand isset($values['SubmitPost']))
  200. {
  201.     store_thread($values);
  202. }
  203.  
  204. /*
  205. ==============================================================================
  206.         FOOTER
  207. ==============================================================================
  208. */
  209.  
  210. ?>

Documentation generated on Thu, 12 Jun 2008 14:07:31 -0500 by phpDocumentor 1.4.1