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
|
|
|
|
2011-02-09 22:11:34 +00:00
|
|
|
check_get_args(array("id", "sort", "start"));
|
|
|
|
|
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);
|
2011-08-25 22:12:48 +00:00
|
|
|
if (!$forum) error_page("forum ID not found");
|
2007-11-12 20:57:15 +00:00
|
|
|
$user = get_logged_in_user(false);
|
2014-04-18 22:54:28 +00:00
|
|
|
BoincForumPrefs::lookup($user);
|
|
|
|
|
|
|
|
if (DISABLE_FORUMS && !is_admin($user)) {
|
|
|
|
error_page("Forums are disabled");
|
|
|
|
}
|
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);
|
|
|
|
}
|
2011-08-25 22:12:48 +00:00
|
|
|
error_page(tra("Not visible to you"));
|
2007-11-25 04:47:54 +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 {
|
2013-05-13 19:29:07 +00:00
|
|
|
list($sort_style, $thread_style) = parse_forum_cookie();
|
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 {
|
2013-05-13 19:29:07 +00:00
|
|
|
list($old_style, $thread_style) = parse_forum_cookie();
|
|
|
|
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:
|
2010-11-04 18:20:57 +00:00
|
|
|
$category = BoincCategory::lookup_id($forum->category);
|
2011-08-25 22:12:48 +00:00
|
|
|
if ($category->is_helpdesk) {
|
2007-11-15 22:51:05 +00:00
|
|
|
page_head(tra("Questions and Answers").' : '.$forum->title);
|
|
|
|
} else {
|
|
|
|
page_head(tra("Message boards").' : '.$forum->title);
|
|
|
|
}
|
|
|
|
show_forum_header($user);
|
|
|
|
show_forum_title($category, $forum, NULL);
|
|
|
|
break;
|
|
|
|
case 1:
|
2010-11-04 18:20:57 +00:00
|
|
|
$team = BoincTeam::lookup_id($forum->category);
|
2011-08-25 22:12:48 +00:00
|
|
|
page_head(tra("Team message board for %1", "<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">
|
2010-12-21 17:15:57 +00:00
|
|
|
<table width="100%" cellspacing="0" cellpadding="0" class="forum_toplinks">
|
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(
|
2011-08-25 22:12:48 +00:00
|
|
|
"forum_post.php?id=$id", tra("New thread"), tra("Add a new thread to this forum")
|
2009-12-16 22:35:08 +00:00
|
|
|
);
|
|
|
|
}
|
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);
|
2014-10-02 19:15:54 +00:00
|
|
|
echo "<input class=\"btn btn-default\" 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 "
|
2011-08-25 22:12:48 +00:00
|
|
|
<p>".
|
|
|
|
tra("This message board is available as an %1RSS feed%2", "<a href=forum_rss.php?forumid=$forum->id&setup=1>", " <img src=img/feed_logo.png></a>");
|
2009-01-13 19:34:04 +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) {
|
2012-07-11 19:24:28 +00:00
|
|
|
$page_nav = page_links(
|
|
|
|
"forum_forum.php?id=$forum->id&sort=$sort_style",
|
2012-07-12 06:40:58 +00:00
|
|
|
$forum->threads,
|
2012-07-11 19:24:28 +00:00
|
|
|
THREADS_PER_PAGE,
|
2012-07-12 06:40:58 +00:00
|
|
|
$start
|
2012-07-11 19:24:28 +00:00
|
|
|
);
|
|
|
|
echo $page_nav;
|
2011-02-10 22:45:39 +00:00
|
|
|
start_forum_table(array(
|
|
|
|
"",
|
|
|
|
tra("Threads"),
|
|
|
|
tra("Posts"),
|
|
|
|
tra("Author"),
|
|
|
|
tra("Views"),
|
2011-08-25 05:08:47 +00:00
|
|
|
"<nobr>".tra("Last post")."</nobr>"
|
|
|
|
));
|
2010-11-04 18:20:57 +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");
|
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
// Run through the list of threads, displaying each of them
|
2012-07-11 19:24:28 +00:00
|
|
|
//
|
2006-06-16 23:53:56 +00:00
|
|
|
$n = 0; $i=0;
|
2007-11-12 20:57:15 +00:00
|
|
|
foreach ($threads as $thread) {
|
|
|
|
$owner = BoincUser::lookup_id($thread->owner);
|
2014-08-29 20:31:30 +00:00
|
|
|
if (!$owner) continue;
|
2007-11-12 20:57:15 +00:00
|
|
|
$unread = thread_is_unread($user, $thread);
|
2010-11-04 18:20:57 +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.
|
2010-11-04 18:20:57 +00:00
|
|
|
echo '<tr class="row'.$n.'">';
|
2007-07-18 15:48:07 +00:00
|
|
|
}
|
2010-11-04 18:20:57 +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) {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(IMAGE_HIDDEN, tra("This thread is hidden"), tra("hidden"));
|
2011-04-11 06:46:22 +00:00
|
|
|
} else if ($unread) {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->sticky) {
|
|
|
|
if ($thread->locked) {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(NEW_IMAGE_STICKY_LOCKED, tra("This thread is sticky and locked, and you haven't read it yet"), tra("sticky/locked/unread"));
|
2007-11-01 20:41:24 +00:00
|
|
|
} else {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(NEW_IMAGE_STICKY, tra("This thread is sticky and you haven't read it yet"), tra("sticky/unread"));
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->locked) {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(NEW_IMAGE_LOCKED, tra("You haven't read this thread yet, and it's locked"), tra("unread/locked"));
|
2007-11-01 20:41:24 +00:00
|
|
|
} else {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(NEW_IMAGE, tra("You haven't read this thread yet"), tra("unread"));
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->sticky) {
|
|
|
|
if ($thread->locked) {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(IMAGE_STICKY_LOCKED, tra("This thread is sticky and locked"), tra("sticky/locked"));
|
2007-11-01 20:41:24 +00:00
|
|
|
} else {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(IMAGE_STICKY, tra("This thread is sticky"), tra("sticky"));
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($thread->locked) {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(IMAGE_LOCKED, tra("This thread is locked"), tra("locked"));
|
2010-11-03 21:48:39 +00:00
|
|
|
} else {
|
2011-08-25 22:12:48 +00:00
|
|
|
show_image(IMAGE_POST, tra("You read this thread"), tra("read"));
|
2010-11-04 18:20:57 +00:00
|
|
|
}
|
2007-11-01 20:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
echo "</nobr></td>";
|
|
|
|
|
2009-12-18 04:32:30 +00:00
|
|
|
$title = cleanup_title($thread->title);
|
2012-05-26 20:08:24 +00:00
|
|
|
//$titlelength = 9999;
|
|
|
|
//if (strlen($title) > $titlelength) {
|
|
|
|
// $title = substr($title, 0, $titlelength)."...";
|
|
|
|
//}
|
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>
|
2014-09-18 17:08:45 +00:00
|
|
|
<td>'.user_links($owner, BADGE_HEIGHT_SMALL).'</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();
|
2012-07-11 19:24:28 +00:00
|
|
|
echo "<br>$page_nav"; // show page links
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
|
|
|
|
2003-11-30 21:05:57 +00:00
|
|
|
?>
|