viewpost.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @deprecated?
  5. *
  6. * @package chamilo.forum
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. // The section (tabs).
  10. $this_section = SECTION_COURSES;
  11. // Notification for unauthorized people.
  12. api_protect_course_script(true);
  13. $nameTools = get_lang('ToolForum');
  14. // Including necessary files.
  15. require 'forumconfig.inc.php';
  16. require_once 'forumfunction.inc.php';
  17. $htmlHeadXtra[] = '<script language="javascript">
  18. $(document).ready(function(){ $(\'.hide-me\').slideUp() });
  19. function hidecontent(content){
  20. $(content).slideToggle(\'normal\');
  21. }
  22. </script>';
  23. // Are we in a lp ?
  24. $origin = api_get_origin();
  25. /* MAIN DISPLAY SECTION */
  26. /* Retrieving forum and forum categorie information */
  27. // We are getting all the information about the current forum and forum category.
  28. // Note pcool: I tried to use only one sql statement (and function) for this,
  29. // but the problem is that the visibility of the forum AND forum category are stored in the item_property table.
  30. $current_thread = get_thread_information($_GET['forum'], $_GET['thread']);
  31. $current_forum = get_forum_information($current_thread['forum_id']);
  32. $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
  33. $whatsnew_post_info = $_SESSION['whatsnew_post_info'];
  34. if (api_is_in_gradebook()) {
  35. $interbreadcrumb[] = [
  36. 'url' => Category::getUrl(),
  37. 'name' => get_lang('ToolGradebook'),
  38. ];
  39. }
  40. if ($origin == 'learnpath') {
  41. Display::display_reduced_header();
  42. } else {
  43. $interbreadcrumb[] = [
  44. 'url' => 'index.php?'.api_get_cidreq().'&search='.Security::remove_XSS(urlencode($_GET['search'])),
  45. 'name' => $nameTools,
  46. ];
  47. $interbreadcrumb[] = [
  48. 'url' => 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.$current_forum_category['cat_id'].'&search='.Security::remove_XSS(urlencode($_GET['search'])),
  49. 'name' => prepare4display($current_forum_category['cat_title']),
  50. ];
  51. $interbreadcrumb[] = [
  52. 'url' => 'viewforum.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&search='.Security::remove_XSS(urlencode($_GET['search'])),
  53. 'name' => prepare4display($current_forum['forum_title']),
  54. ];
  55. // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
  56. Display :: display_header('');
  57. api_display_tool_title($nameTools);
  58. }
  59. /* Is the user allowed here? */
  60. // if the user is not a course administrator and the forum is hidden
  61. // then the user is not allowed here.
  62. if (!api_is_allowed_to_edit(false, true) &&
  63. ($current_forum['visibility'] == 0 || $current_thread['visibility'] == 0)
  64. ) {
  65. api_not_allowed(false);
  66. }
  67. /* Actions */
  68. if ($_GET['action'] == 'delete' &&
  69. isset($_GET['content']) &&
  70. isset($_GET['id']) && api_is_allowed_to_edit(false, true)
  71. ) {
  72. $message = delete_post($_GET['id']);
  73. }
  74. if (($_GET['action'] == 'invisible' || $_GET['action'] == 'visible') &&
  75. isset($_GET['id']) && api_is_allowed_to_edit(false, true)
  76. ) {
  77. $message = approve_post($_GET['id'], $_GET['action']);
  78. }
  79. if ($_GET['action'] == 'move' && isset($_GET['post'])) {
  80. $message = move_post_form();
  81. }
  82. /* Display the action messages */
  83. if (!empty($message)) {
  84. echo Display::return_message(get_lang($message), 'confirm');
  85. }
  86. // In this case the first and only post of the thread is removed.
  87. if ($message != 'PostDeletedSpecial') {
  88. // This increases the number of times the thread has been viewed.
  89. increase_thread_view($_GET['thread']);
  90. /* Action Links */
  91. echo '<div style="float:right;">';
  92. $my_url = '<a href="viewthread.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&search='.Security::remove_XSS(urlencode($_GET['search']));
  93. echo $my_url.'&view=flat">'.get_lang('FlatView').'</a> | ';
  94. echo $my_url.'&view=threaded">'.get_lang('ThreadedView').'</a> | ';
  95. echo $my_url.'&view=nested">'.get_lang('NestedView').'</a>';
  96. $my_url = null;
  97. echo '</div>';
  98. // The reply to thread link should only appear when the forum_category is
  99. // not locked AND the forum is not locked AND the thread is not locked.
  100. // If one of the three levels is locked then the link should not be displayed.
  101. if (($current_forum_category && $current_forum_category['locked'] == 0) &&
  102. $current_forum['locked'] == 0 && $current_thread['locked'] == 0 || api_is_allowed_to_edit(false, true)
  103. ) {
  104. // The link should only appear when the user is logged in or when anonymous posts are allowed.
  105. if ($_user['user_id'] || ($current_forum['allow_anonymous'] == 1 && !$_user['user_id'])) {
  106. // reply link
  107. echo '<a href="reply.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&action=replythread">'.get_lang('ReplyToThread').'</a>';
  108. // new thread link
  109. if (api_is_allowed_to_edit(false, true) ||
  110. ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) ||
  111. ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1)
  112. ) {
  113. if ($current_forum['locked'] != 1 && $current_forum['locked'] != 1) {
  114. echo '&nbsp;&nbsp;';
  115. /*echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('new_thread.png','','',ICON_SIZE_MEDIUM).'</a>';*/
  116. } else {
  117. echo get_lang('ForumLocked');
  118. }
  119. }
  120. }
  121. }
  122. // Note: This is to prevent that some browsers display the links over the table (FF does it but Opera doesn't).
  123. echo '&nbsp;';
  124. /* Display Forum Category and the Forum information */
  125. if (!$_SESSION['view']) {
  126. $viewmode = $current_forum['default_view'];
  127. } else {
  128. $viewmode = $_SESSION['view'];
  129. }
  130. $viewmode_whitelist = ['flat', 'threaded', 'nested'];
  131. if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
  132. $viewmode = Database::escape_string($_GET['view']);
  133. $_SESSION['view'] = $viewmode;
  134. }
  135. if (empty($viewmode)) {
  136. $viewmode = 'flat';
  137. }
  138. /* Display Forum Category and the Forum information */
  139. // we are getting all the information about the current forum and forum category.
  140. // note pcool: I tried to use only one sql statement (and function) for this
  141. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
  142. echo "<table class=\"data_table\" width=\"100%\">\n";
  143. // The thread
  144. echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
  145. echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
  146. if ($origin != 'learnpath') {
  147. echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' - ';
  148. }
  149. echo prepare4display($current_forum['forum_title']).'<br />';
  150. echo "</th>\n";
  151. echo "\t</tr>\n";
  152. echo '<span>'.prepare4display($current_thread['thread_comment']).'</span>';
  153. echo "</table>";
  154. include_once 'viewpost.inc.php';
  155. }
  156. if ($origin != 'learnpath') {
  157. Display :: display_footer();
  158. }