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