2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
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);
|
2010-03-26 05:34:14 +00:00
|
|
|
if (!$forum) error_page("no forum");
|
2007-11-12 20:57:15 +00:00
|
|
|
$user = get_logged_in_user(false);
|
2007-11-25 04:47:54 +00:00
|
|
|
|
|
|
|
if (!is_forum_visible_to_user($forum, $user)) {
|
2010-03-26 05:34:14 +00:00
|
|
|
if ($user) {
|
|
|
|
remove_subscriptions_forum($user->id, $id);
|
|
|
|
}
|
2007-11-25 04:47:54 +00:00
|
|
|
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']);
|
2008-02-13 19:02:44 +00:00
|
|
|
send_cookie('sorting', implode("|",array($sort_style,$thread_style)), true);
|
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);
|
2007-11-26 04:12:15 +00:00
|
|
|
show_team_forum_title($forum);
|
2007-11-15 22:51:05 +00:00
|
|
|
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>
|
2008-10-05 12:35:44 +00:00
|
|
|
<form action="forum_forum.php" method="get">
|
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
|
|
|
|
2009-12-16 22:35:08 +00:00
|
|
|
if (user_can_create_thread($user, $forum)) {
|
|
|
|
show_button(
|
|
|
|
"forum_post.php?id=$id", "New thread", "Add a new thread to this forum"
|
|
|
|
);
|
|
|
|
}
|
2007-11-01 17:54:44 +00:00
|
|
|
|
2008-08-07 22:04:08 +00:00
|
|
|
echo "</td>
|
2009-09-29 21:58:54 +00:00
|
|
|
<td valign=top align=\"right\">
|
2008-08-07 22:04:08 +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);
|
2008-08-07 22:04:08 +00:00
|
|
|
echo "<input type=\"submit\" value=\"Sort\">
|
2009-09-29 21:58:54 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
2008-08-07 22:04:08 +00:00
|
|
|
";
|
2006-06-16 23:53:56 +00:00
|
|
|
|
|
|
|
show_forum($forum, $start, $sort_style, $user);
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2009-01-13 19:34:04 +00:00
|
|
|
echo "
|
|
|
|
<p>
|
|
|
|
This message board is available as an
|
|
|
|
<a href=forum_rss.php?forumid=$forum->id&setup=1>RSS feed
|
|
|
|
<img src=img/feed_logo.png></a>
|
|
|
|
";
|
|
|
|
|
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
|
2010-11-03 21:48:39 +00:00
|
|
|
start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>".tra("Last post")."</nobr>"), "id=\"catview\" cellspacing=0");
|
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
|
|
|
}
|
|
|
|
|
2010-11-03 21:48:39 +00:00
|
|
|
echo "<td width=\"1%\" class=\"threadicon\"><nobr>";
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->hidden) {
|
2010-11-03 21:48:39 +00:00
|
|
|
echo "[".tra("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");
|
2010-11-03 21:48:39 +00:00
|
|
|
} else {
|
|
|
|
show_image(IMAGE_POST, "You read this thread", "read");
|
|
|
|
}
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
echo "</nobr></td>";
|
|
|
|
|
|
|
|
$titlelength = 48;
|
2009-12-18 04:32:30 +00:00
|
|
|
$title = cleanup_title($thread->title);
|
2006-06-16 23:53:56 +00:00
|
|
|
if (strlen($title) > $titlelength) {
|
2009-12-18 04:32:30 +00:00
|
|
|
$title = substr($title, 0, $titlelength)."...";
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2009-12-18 04:32:30 +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 '
|
2010-11-03 21:48:39 +00:00
|
|
|
<td class="numbers">'.($thread->replies+1).'</td>
|
2008-08-10 01:13:00 +00:00
|
|
|
<td>'.user_links($owner).'</td>
|
2010-11-03 21:48:39 +00:00
|
|
|
<td class="numbers">'.$thread->views.'</td>
|
|
|
|
<td class="lastpost">'.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
|
|
|
?>
|