iframe_thread.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. require_once '../inc/global.inc.php';
  23. /* ACCESS RIGHTS */
  24. // A notice for unauthorized people.
  25. api_protect_course_script(true);
  26. $nameTools = get_lang('ToolForum');
  27. Display::display_reduced_header();
  28. /* Including necessary files */
  29. require 'forumconfig.inc.php';
  30. require_once 'forumfunction.inc.php';
  31. /* MAIN DISPLAY SECTION */
  32. /* Retrieving forum and forum categorie information */
  33. // We are getting all the information about the current forum and forum category.
  34. // Note pcool: I tried to use only one sql statement (and function) for this,
  35. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
  36. $current_thread=get_thread_information($_GET['thread']); // Note: this has to be validated that it is an existing thread.
  37. $current_forum=get_forum_information($current_thread['forum_id']); // Note: this has to be validated that it is an existing forum.
  38. $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
  39. /* Is the user allowed here? */
  40. // if the user is not a course administrator and the forum is hidden
  41. // then the user is not allowed here.
  42. if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 OR $current_thread['visibility'] == 0)) {
  43. $forum_allow = forum_not_allowed_here();
  44. if ($forum_allow === false) {
  45. exit;
  46. }
  47. }
  48. $course_id = api_get_course_int_id();
  49. /* Display Forum Category and the Forum information */
  50. // We are getting all the information about the current forum and forum category.
  51. // Note pcool: I tried to use only one sql statement (and function) for this,
  52. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
  53. $sql = "SELECT * FROM $table_posts posts, $table_users users
  54. WHERE
  55. posts.c_id = $course_id AND
  56. posts.thread_id='".$current_thread['thread_id']."' AND
  57. posts.poster_id=users.user_id
  58. ORDER BY posts.post_id ASC";
  59. $result = Database::query($sql);
  60. echo "<table width=\"100%\" height=\"100%\" cellspacing=\"5\" border=\"0\">";
  61. while ($row = Database::fetch_array($result)) {
  62. echo "<tr>";
  63. echo "<td rowspan=\"2\" class=\"forum_message_left\">";
  64. $username = api_htmlentities(sprintf(get_lang('LoginX'), $row['username']), ENT_QUOTES);
  65. if ($row['user_id']=='0') {
  66. $name = $row['poster_name'];
  67. } else {
  68. $name = api_get_person_name($row['firstname'], $row['lastname']);
  69. }
  70. echo Display::tag('span', $name, array('title'=>$username)).'<br />';
  71. echo api_convert_and_format_date($row['post_date']).'<br /><br />';
  72. echo "</td>";
  73. echo "<td class=\"forum_message_post_title\">".Security::remove_XSS($row['post_title'])."</td>";
  74. echo "</tr>";
  75. echo "<tr>";
  76. echo "<td class=\"forum_message_post_text\">".Security::remove_XSS($row['post_text'], STUDENT)."</td>";
  77. echo "</tr>";
  78. }
  79. echo "</table>";
  80. ?>
  81. </body>
  82. </html>