iframe_thread.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. use Chamilo\CoreBundle\Framework\Container;
  5. /**
  6. * These files are a complete rework of the forum. The database structure is
  7. * based on phpBB but all the code is rewritten. A lot of new functionalities
  8. * are added:
  9. * - forum categories and forums can be sorted up or down, locked or made invisible
  10. * - consistent and integrated forum administration
  11. * - forum options: are students allowed to edit their post?
  12. * moderation of posts (approval)
  13. * reply only forums (students cannot create new threads)
  14. * multiple forums per group
  15. * - sticky messages
  16. * - new view option: nested view
  17. * - quoting a message
  18. *
  19. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  20. * @copyright Ghent University
  21. *
  22. * @package chamilo.forum
  23. */
  24. // A notice for unauthorized people.
  25. api_protect_course_script(true);
  26. $nameTools = get_lang('ToolForum');
  27. /* Including necessary files */
  28. require 'forumconfig.inc.php';
  29. require_once 'forumfunction.inc.php';
  30. /* Retrieving forum and forum categorie information */
  31. // We are getting all the information about the current forum and forum category.
  32. // Note pcool: I tried to use only one sql statement (and function) for this,
  33. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
  34. $current_thread = get_thread_information(
  35. $_GET['forum'],
  36. $_GET['thread']
  37. ); // Note: this has to be validated that it is an existing thread.
  38. $current_forum = get_forum_information($current_thread['forum_id']);
  39. // Note: this has to be validated that it is an existing forum.
  40. $current_forum_category = get_forumcategory_information(
  41. $current_forum['forum_category']
  42. );
  43. /* Is the user allowed here? */
  44. // if the user is not a course administrator and the forum is hidden
  45. // then the user is not allowed here.
  46. if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 OR $current_thread['visibility'] == 0)) {
  47. $forum_allow = forum_not_allowed_here();
  48. if ($forum_allow === false) {
  49. exit;
  50. }
  51. }
  52. $course_id = api_get_course_int_id();
  53. /* Display Forum Category and the Forum information */
  54. // We are getting all the information about the current forum and forum category.
  55. // Note pcool: I tried to use only one sql statement (and function) for this,
  56. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
  57. $sql = "SELECT * FROM $table_posts posts, $table_users users
  58. WHERE
  59. posts.c_id = $course_id AND
  60. posts.thread_id='".$current_thread['thread_id']."' AND
  61. posts.poster_id=users.user_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, array('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. // Hide headers
  85. Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';