2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
// display the threads in a forum.
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
require_once('../inc/util.inc');
|
|
|
|
require_once('../inc/time.inc');
|
|
|
|
require_once('../inc/forum.inc');
|
|
|
|
require_once('../inc/pm.inc');
|
2004-12-27 03:42:11 +00:00
|
|
|
|
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
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$forum = BoincForum::lookup_id($id);
|
|
|
|
$user = get_logged_in_user(false);
|
2007-11-25 04:47:54 +00:00
|
|
|
|
|
|
|
if (!is_forum_visible_to_user($forum, $user)) {
|
|
|
|
error_page("Not visible");
|
|
|
|
}
|
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
BoincForumPrefs::lookup($user);
|
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-11-12 20:57:15 +00:00
|
|
|
$sort_style = $user->prefs->forum_sorting;
|
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){
|
2007-11-12 20:57:15 +00:00
|
|
|
$user->prefs->forum_sorting = $sort_style;
|
|
|
|
$user->prefs->update("forum_sorting=$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
|
|
|
|
2007-11-15 22:51:05 +00:00
|
|
|
switch ($forum->parent_type) {
|
|
|
|
case 0:
|
|
|
|
$category = BoincCategory::lookup_id($forum->category);
|
|
|
|
if ($category->is_helpdesk){
|
|
|
|
page_head(tra("Questions and Answers").' : '.$forum->title);
|
|
|
|
echo '<link href="forum_help_desk.php" rel="up" title="Forum Index">';
|
|
|
|
} else {
|
|
|
|
page_head(tra("Message boards").' : '.$forum->title);
|
|
|
|
echo '<link href="forum_index.php" rel="up" title="Forum Index">';
|
|
|
|
}
|
|
|
|
show_forum_header($user);
|
|
|
|
show_forum_title($category, $forum, NULL);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$team = BoincTeam::lookup_id($forum->category);
|
2007-11-16 22:23:16 +00:00
|
|
|
page_head("Team message board for <a href=team_display.php?teamid=$team->id>$team->name</a>");
|
2007-11-15 22:51:05 +00:00
|
|
|
show_forum_header($user);
|
|
|
|
break;
|
|
|
|
}
|
2007-04-29 14:22:28 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
echo '
|
2007-11-20 19:23:26 +00:00
|
|
|
<p>
|
2006-06-16 23:53:56 +00:00
|
|
|
<table width="100%" cellspacing="0" cellpadding="0">
|
2007-11-15 22:51:05 +00:00
|
|
|
<tr valign="top">
|
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());
|
2007-11-12 20:57:15 +00:00
|
|
|
$tokens = url_tokens($user->authenticator);
|
|
|
|
$url = "forum_index.php?read=1$tokens&return=$return";
|
2007-11-01 17:54:44 +00:00
|
|
|
show_button($url, "Mark all threads as read", "Mark all threads in this forum as 'read'.");
|
|
|
|
}
|
|
|
|
|
|
|
|
echo " <br><br></td>";
|
2007-11-15 22:51:05 +00:00
|
|
|
echo '<td valign=top align="right">';
|
2006-06-16 23:53:56 +00:00
|
|
|
echo ' <form action="forum_forum.php" method="get">
|
2007-11-12 20:57:15 +00:00
|
|
|
<input type="hidden" name="id" value="'.$forum->id.'">';
|
2007-01-03 18:07:44 +00:00
|
|
|
echo select_from_array("sort", $forum_sort_styles, $sort_style);
|
2007-11-15 22:51:05 +00:00
|
|
|
echo '<input type="submit" value="Sort"></form></td>';
|
|
|
|
echo "</tr></table>";
|
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
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
// This function shows the threads for the given forum
|
2007-11-05 23:55:33 +00:00
|
|
|
// Starting from $start,
|
|
|
|
// using the given $sort_style (as defined in forum.php)
|
|
|
|
// and using the features for the logged in user in $user.
|
|
|
|
//
|
2006-06-16 23:53:56 +00:00
|
|
|
function show_forum($forum, $start, $sort_style, $user) {
|
2007-11-15 22:51:05 +00:00
|
|
|
$gotoStr = "";
|
|
|
|
$nav = show_page_nav($forum, $start);
|
|
|
|
if ($nav) {
|
|
|
|
$gotoStr = "<div align=\"right\">$nav</div><br>";
|
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
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
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$sticky_first = !$user || !$user->prefs->ignore_sticky_posts;
|
2007-11-22 04:13:59 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Show hidden threads if logged in user is a moderator
|
2007-11-15 22:51:05 +00:00
|
|
|
//
|
|
|
|
$show_hidden = is_moderator($user, $forum);
|
2007-11-12 20:57:15 +00:00
|
|
|
$threads = get_forum_threads(
|
|
|
|
$forum->id, $start, THREADS_PER_PAGE,
|
|
|
|
$sort_style, $show_hidden, $sticky_first
|
|
|
|
);
|
2007-11-22 04:13:59 +00:00
|
|
|
|
|
|
|
if ($user) {
|
|
|
|
$subs = BoincSubscription::enum("userid=$user->id");
|
|
|
|
}
|
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;
|
2007-11-12 20:57:15 +00:00
|
|
|
foreach ($threads as $thread) {
|
|
|
|
$owner = BoincUser::lookup_id($thread->owner);
|
|
|
|
$unread = thread_is_unread($user, $thread);
|
2007-07-18 15:48:07 +00:00
|
|
|
|
2007-11-21 00:46:54 +00:00
|
|
|
//if ($thread->status==1){
|
2007-07-18 15:48:07 +00:00
|
|
|
// This is an answered helpdesk thread
|
2007-11-22 04:13:59 +00:00
|
|
|
if ($user && is_subscribed($thread, $subs)) {
|
2007-07-18 15:48:07 +00:00
|
|
|
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>";
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($user && ($thread->rating()>$user->prefs->high_rating_threshold)) {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(EMPHASIZE_IMAGE, "This message has a high average rating", "Highly rated");
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($user && ($thread->rating()<$user->prefs->low_rating_threshold)) {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(FILTER_IMAGE, "This message has a low average rating", "Low rated");
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->hidden) {
|
|
|
|
echo "[hidden]";
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-01 20:41:24 +00:00
|
|
|
if ($unread) {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->sticky) {
|
|
|
|
if ($thread->locked) {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(NEW_IMAGE_STICKY_LOCKED, "This thread is sticky and locked, and you haven't read it yet", "sticky/locked/unread");
|
2007-11-01 20:41:24 +00:00
|
|
|
} else {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(NEW_IMAGE_STICKY, "This thread is sticky and you haven't read it yet", "sticky/unread");
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->locked) {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(NEW_IMAGE_LOCKED, "You haven't read this thread yet, and it's locked", "unread/locked");
|
2007-11-01 20:41:24 +00:00
|
|
|
} else {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(NEW_IMAGE, "You haven't read this thread yet", "unread");
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->sticky) {
|
|
|
|
if ($thread->locked) {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(IMAGE_STICKY_LOCKED, "This thread is sticky and locked", "sticky/locked");
|
2007-11-01 20:41:24 +00:00
|
|
|
} else {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(IMAGE_STICKY, "This thread is sticky", "sticky");
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->locked) {
|
2007-11-23 21:05:52 +00:00
|
|
|
show_image(IMAGE_LOCKED, "This thread is locked", "locked");
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
echo "</nobr></td>";
|
|
|
|
|
|
|
|
$titlelength = 48;
|
2007-11-12 20:57:15 +00:00
|
|
|
$title = $thread->title;
|
2006-06-16 23:53:56 +00:00
|
|
|
if (strlen($title) > $titlelength) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$title = substr($title,0,$titlelength)."...";
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2006-12-23 14:59:47 +00:00
|
|
|
$title = cleanup_title($title);
|
2007-11-12 20:57:15 +00:00
|
|
|
echo '<td class="threadline"><a href="forum_thread.php?id='.$thread->id.'"><b>'.$title.'</b></a><br></td>';
|
2006-06-16 23:53:56 +00:00
|
|
|
$n = ($n+1)%2;
|
|
|
|
|
|
|
|
echo '
|
2007-11-12 20:57:15 +00:00
|
|
|
<td>'.($thread->replies+1).'</td>
|
|
|
|
<td align="left"><div class="authorcol">'.user_links($owner).'</div></td>
|
|
|
|
<td>'.$thread->views.'</td>
|
|
|
|
<td style="text-align:right">'.time_diff_str($thread->timestamp, time()).'</td>
|
2007-11-01 20:41:24 +00:00
|
|
|
</tr>
|
|
|
|
';
|
|
|
|
flush();
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
end_table();
|
2007-11-05 23:55:33 +00:00
|
|
|
echo "<br>$gotoStr"; // show page links
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
|
|
|
|
2003-11-30 21:05:57 +00:00
|
|
|
?>
|