iframe_thread.php 3.7 KB

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