2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2006-06-16 23:53:56 +00:00
|
|
|
/**
|
|
|
|
* This page displays the threads in a forum.
|
|
|
|
**/
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once('../inc/forum.inc');
|
2006-06-16 23:53:56 +00:00
|
|
|
require_once('../inc/forum_std.inc');
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2004-12-27 03:42:11 +00:00
|
|
|
db_init();
|
|
|
|
|
2005-02-13 06:13:33 +00:00
|
|
|
$id = get_int("id");
|
2006-06-16 23:53:56 +00:00
|
|
|
$sort_style = get_int("sort", true);
|
2005-02-13 06:13:33 +00:00
|
|
|
$start = get_int("start", true);
|
|
|
|
if (!$start) $start = 0;
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$forum = new Forum($id);
|
|
|
|
$user = re_get_logged_in_user(false);
|
2003-08-01 20:30:25 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
if (!$sort_style) {
|
|
|
|
// get the sort style either from the logged in user or a cookie
|
|
|
|
if ($user){
|
2007-07-18 15:48:07 +00:00
|
|
|
$sort_style = $user->getForumSortStyle();
|
2004-01-19 01:12:53 +00:00
|
|
|
} else {
|
2007-10-22 19:36:01 +00:00
|
|
|
if (isset($_COOKIE['sorting'])) {
|
|
|
|
list($sort_style,$thread_style)=explode("|",$_COOKIE['sorting']);
|
|
|
|
}
|
2004-01-19 01:12:53 +00:00
|
|
|
}
|
2003-08-01 20:30:25 +00:00
|
|
|
} else {
|
2006-06-16 23:53:56 +00:00
|
|
|
// set the sort style
|
|
|
|
if ($user){
|
2006-11-10 17:09:09 +00:00
|
|
|
$user->setForumSortStyle($sort_style);
|
2004-01-19 01:12:53 +00:00
|
|
|
} else {
|
2006-06-16 23:53:56 +00:00
|
|
|
list($old_style,$thread_style)=explode("|",$_COOKIE['sorting']);
|
|
|
|
setcookie('sorting', implode("|",array($sort_style,$thread_style)), time()+3600*24*365);
|
2004-01-19 01:12:53 +00:00
|
|
|
}
|
2003-07-30 00:50:54 +00:00
|
|
|
}
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2006-08-09 19:12:54 +00:00
|
|
|
$Category = $forum->getCategory();
|
|
|
|
if ($Category->getType()!=0){
|
2007-11-02 14:43:02 +00:00
|
|
|
page_head(tra("Questions and Answers").' : '.$forum->getTitle());
|
2006-08-09 19:12:54 +00:00
|
|
|
} else {
|
2007-11-02 14:43:02 +00:00
|
|
|
page_head(tra("Message boards").' : '.$forum->getTitle());
|
2006-08-09 19:12:54 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Allow users with a linktab-browser to get some usefull links
|
|
|
|
echo '<link href="forum_index.php" rel="up" title="Forum Index">';
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2007-04-29 14:22:28 +00:00
|
|
|
show_forum_title($forum, NULL);
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
echo '
|
|
|
|
<table width="100%" cellspacing="0" cellpadding="0">
|
|
|
|
<tr valign="bottom">
|
2007-11-01 17:54:44 +00:00
|
|
|
<td colspan=2>
|
|
|
|
';
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2007-11-01 17:54:44 +00:00
|
|
|
show_button("forum_post.php?id=$id", "New thread", "Add a new thread to this forum");
|
|
|
|
|
|
|
|
if ($user) {
|
|
|
|
$return = urlencode(current_url());
|
|
|
|
$tokens = url_tokens($user->dbObj->authenticator);
|
|
|
|
$url = "forum_index.php?read=1&$tokens&return=$return";
|
|
|
|
show_button($url, "Mark all threads as read", "Mark all threads in this forum as 'read'.");
|
|
|
|
}
|
|
|
|
|
|
|
|
echo " <br><br></td>";
|
2006-06-16 23:53:56 +00:00
|
|
|
echo ' <form action="forum_forum.php" method="get">
|
|
|
|
<input type="hidden" name="id" value="'.$forum->getID().'">';
|
|
|
|
echo '<td align="right">';
|
2007-01-03 18:07:44 +00:00
|
|
|
echo select_from_array("sort", $forum_sort_styles, $sort_style);
|
2007-11-01 23:04:39 +00:00
|
|
|
echo '<input type="submit" value="Sort"><br><br></td>';
|
2003-08-13 22:08:12 +00:00
|
|
|
echo "</tr>\n</table>\n</form>";
|
2006-06-16 23:53:56 +00:00
|
|
|
|
|
|
|
show_forum($forum, $start, $sort_style, $user);
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-15 01:01:00 +00:00
|
|
|
page_tail();
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
/**
|
|
|
|
* This function shows the threadlist for the given forum
|
|
|
|
* Starting from $start,
|
|
|
|
* using the given $sort_style (as defined in forum.php)
|
|
|
|
* and using the features for the logged in user in $user.
|
|
|
|
**/
|
|
|
|
function show_forum($forum, $start, $sort_style, $user) {
|
|
|
|
$gotoStr = "<div align=\"right\">".show_page_nav($forum,$start)."</div>";
|
|
|
|
echo $gotoStr; // Display the navbar
|
2007-11-02 14:43:02 +00:00
|
|
|
start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>".tra("Last post")."</nobr>"));
|
2007-07-18 15:48:07 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
$sticky_first = !$user || !$user->hasIgnoreStickyPosts();
|
|
|
|
// Show hidden threads if logged in user is a moderator
|
|
|
|
$show_hidden = $user && $user->isSpecialUser(S_MODERATOR);
|
|
|
|
$threads = $forum->getThreads($start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first);
|
2007-07-18 15:48:07 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Run through the list of threads, displaying each of them
|
|
|
|
$n = 0; $i=0;
|
|
|
|
foreach ($threads as $key => $thread) {
|
|
|
|
$owner = $thread->getOwner();
|
2007-07-18 15:48:07 +00:00
|
|
|
$timestamp = $thread->getLastTimestamp();
|
|
|
|
$unread = $user && ($timestamp>$thread->getLastReadTimestamp($user)) && ($timestamp > $user->getReadTimestamp());
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
if ($thread->getStatus()==1){
|
2007-07-18 15:48:07 +00:00
|
|
|
// This is an answered helpdesk thread
|
|
|
|
echo '<tr class="row_hd'.$n.'">';
|
|
|
|
} else {
|
|
|
|
// Just a standard thread.
|
2007-11-01 20:41:24 +00:00
|
|
|
echo '<tr class="row'.$n.'">';
|
2007-07-18 15:48:07 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
echo "<td width=\"1%\" align=\"right\"><nobr>";
|
|
|
|
if ($user && ($thread->getRating()>$user->getHighRatingThreshold())) {
|
2007-11-01 20:41:24 +00:00
|
|
|
show_image(EMPHASIZE_IMAGE, "This message has a high average rating");
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
|
|
|
if ($user && ($thread->getRating()<$user->getLowRatingThreshold())) {
|
2007-11-01 20:41:24 +00:00
|
|
|
show_image(FILTER_IMAGE, "This message has a low average rating");
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
|
|
|
if ($thread->isHidden()) {
|
|
|
|
echo "X";
|
|
|
|
}
|
2007-11-01 20:41:24 +00:00
|
|
|
if ($unread) {
|
|
|
|
if ($thread->isSticky()) {
|
|
|
|
if ($thread->isLocked()) {
|
|
|
|
show_image(NEW_IMAGE_STICKY_LOCKED, "This thread is sticky and locked, and you haven't read it yet");
|
|
|
|
} else {
|
|
|
|
show_image(NEW_IMAGE_STICKY, "This thread is sticky and you haven't read it yet");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($thread->isLocked()) {
|
|
|
|
show_image(NEW_IMAGE_LOCKED, "You haven't read this thread yet, and it's locked");
|
|
|
|
} else {
|
|
|
|
show_image(NEW_IMAGE, "You haven't read this thread yet");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($thread->isSticky()) {
|
|
|
|
if ($thread->isLocked()) {
|
|
|
|
show_image(IMAGE_STICKY_LOCKED, "This thread is sticky and locked");
|
|
|
|
} else {
|
|
|
|
show_image(IMAGE_STICKY, "This thread is sticky");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($thread->isLocked()) {
|
|
|
|
show_image(IMAGE_LOCKED, "This thread is locked");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
echo "</nobr></td>";
|
|
|
|
|
|
|
|
$titlelength = 48;
|
2006-12-23 14:59:47 +00:00
|
|
|
$title = $thread->getTitle();
|
2006-06-16 23:53:56 +00:00
|
|
|
if (strlen($title) > $titlelength) {
|
|
|
|
$title = substr($title,0,$titlelength)."...";
|
|
|
|
}
|
2006-12-23 14:59:47 +00:00
|
|
|
$title = cleanup_title($title);
|
2006-06-16 23:53:56 +00:00
|
|
|
echo '<td class="threadline"><a href="forum_thread.php?id='.$thread->getID().'"><b>'.$title.'</b></a><br></td>';
|
|
|
|
$n = ($n+1)%2;
|
|
|
|
|
|
|
|
echo '
|
2007-11-01 20:41:24 +00:00
|
|
|
<td>'.($thread->getPostCount()+1).'</td>
|
|
|
|
<td align="left"><div class="authorcol">'.re_user_links($owner).'</div></td>
|
|
|
|
<td>'.$thread->getViewCount().'</td>
|
|
|
|
<td style="text-align:right">'.time_diff_str($thread->getLastTimestamp(), time()).'</td>
|
|
|
|
</tr>
|
|
|
|
';
|
|
|
|
flush();
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
|
|
|
end_forum_table();
|
|
|
|
echo $gotoStr; // Display the navigation bar at the bottom as well.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-30 21:05:57 +00:00
|
|
|
?>
|