viewpost.php 7.6 KB

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