iframe_thread.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * These files are a complete rework of the forum. The database structure is
  5. * based on phpBB but all the code is rewritten. A lot of new functionalities
  6. * are added:
  7. * - forum categories and forums can be sorted up or down, locked or made invisible
  8. * - consistent and integrated forum administration
  9. * - forum options: are students allowed to edit their post?
  10. * moderation of posts (approval)
  11. * reply only forums (students cannot create new threads)
  12. * multiple forums per group
  13. * - sticky messages
  14. * - new view option: nested view
  15. * - quoting a message
  16. *
  17. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  18. * @copyright Ghent University
  19. *
  20. * @package chamilo.forum
  21. */
  22. /* INIT SECTION */
  23. /* Language Initialisation */
  24. // Name of the language file that needs to be included
  25. $language_file = 'forum';
  26. //$this_section = SECTION_COURSES;
  27. require_once '../inc/global.inc.php';
  28. /* ACCESS RIGHTS */
  29. // A notice for unauthorized people.
  30. api_protect_course_script(true);
  31. $nameTools = get_lang('ToolForum');
  32. Display::display_reduced_header();
  33. /* Including necessary files */
  34. require 'forumconfig.inc.php';
  35. require_once 'forumfunction.inc.php';
  36. /* MAIN DISPLAY SECTION */
  37. /* Retrieving forum and forum categorie information */
  38. // We are getting all the information about the current forum and forum category.
  39. // Note pcool: I tried to use only one sql statement (and function) for this,
  40. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
  41. $current_thread=get_thread_information($_GET['thread']); // Note: this has to be validated that it is an existing thread.
  42. $current_forum=get_forum_information($current_thread['forum_id']); // Note: this has to be validated that it is an existing forum.
  43. $current_forum_category=get_forumcategory_information($current_forum['forum_category']);
  44. /* Is the user allowed here? */
  45. // if the user is not a course administrator and the forum is hidden
  46. // then the user is not allowed here.
  47. if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 OR $current_thread['visibility'] == 0)) {
  48. $forum_allow = forum_not_allowed_here();
  49. if ($forum_allow === false) {
  50. exit;
  51. }
  52. }
  53. $course_id = api_get_course_int_id();
  54. /* Display Forum Category and the Forum information */
  55. // We are getting all the information about the current forum and forum category.
  56. // Note pcool: I tried to use only one sql statement (and function) for this,
  57. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
  58. $sql = "SELECT * FROM $table_posts posts, $table_users users
  59. WHERE
  60. posts.c_id = $course_id AND
  61. posts.thread_id='".$current_thread['thread_id']."'
  62. AND posts.poster_id=users.user_id
  63. ORDER BY posts.post_id ASC";
  64. $result = Database::query($sql);
  65. echo "<table width=\"100%\" cellspacing=\"5\" border=\"0\">";
  66. while ($row = Database::fetch_array($result)) {
  67. echo "<tr>";
  68. echo "<td rowspan=\"2\" class=\"forum_message_left\">";
  69. $username = api_htmlentities(sprintf(get_lang('LoginX'), $row['username']), ENT_QUOTES);
  70. if ($row['user_id']=='0') {
  71. $name = $row['poster_name'];
  72. } else {
  73. $name = api_get_person_name($row['firstname'], $row['lastname']);
  74. }
  75. echo Display::tag('span', $name, array('title'=>$username)).'<br />';
  76. echo api_convert_and_format_date($row['post_date']).'<br /><br />';
  77. echo "</td>";
  78. echo "<td class=\"forum_message_post_title\">".Security::remove_XSS($row['post_title'])."</td>";
  79. echo "</tr>";
  80. echo "<tr>";
  81. echo "<td class=\"forum_message_post_text\">".Security::remove_XSS($row['post_text'], STUDENT)."</td>";
  82. echo "</tr>";
  83. }
  84. echo "</table>";
  85. ?>
  86. </body>
  87. </html>