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/>.
2007-11-12 20:57:15 +00:00
// display the contents of a thread.
2003-08-13 22:08:12 +00:00
2007-11-12 20:57:15 +00:00
require_once ( '../inc/util.inc' );
2004-02-02 23:34:39 +00:00
require_once ( '../inc/forum.inc' );
2004-12-27 03:42:11 +00:00
2005-04-28 09:32:22 +00:00
$threadid = get_int ( 'id' );
2006-06-16 23:53:56 +00:00
$sort_style = get_int ( 'sort' , true );
2005-04-28 09:32:22 +00:00
$filter = get_str ( 'filter' , true );
2003-07-18 21:38:51 +00:00
2004-10-25 22:04:15 +00:00
if ( $filter != " false " ){
$filter = true ;
} else {
$filter = false ;
2003-07-30 00:51:44 +00:00
}
2007-11-12 20:57:15 +00:00
$logged_in_user = get_logged_in_user ( false );
2007-11-02 18:48:48 +00:00
$tokens = " " ;
2007-02-09 21:07:51 +00:00
if ( $logged_in_user ) {
2007-11-12 20:57:15 +00:00
BoincForumPrefs :: lookup ( $logged_in_user );
$tokens = url_tokens ( $logged_in_user -> authenticator );
2007-02-09 21:07:51 +00:00
}
2006-12-30 18:35:25 +00:00
2007-11-12 20:57:15 +00:00
$thread = BoincThread :: lookup_id ( $threadid );
2007-11-15 22:51:05 +00:00
$forum = BoincForum :: lookup_id ( $thread -> forum );
2004-01-19 01:12:53 +00:00
2008-12-13 20:04:01 +00:00
if ( ! $thread ) error_page ( tra ( " No thread with id %1. Please check the link and try again. " , $threadid ));
2007-11-25 04:47:54 +00:00
if ( ! is_forum_visible_to_user ( $forum , $logged_in_user )) {
2008-12-13 20:04:01 +00:00
error_page ( tra ( " This forum is not visible to you. " ));
2007-11-25 04:47:54 +00:00
}
2007-11-12 20:57:15 +00:00
if ( $thread -> hidden ) {
2007-11-15 22:51:05 +00:00
if ( ! is_moderator ( $logged_in_user , $forum )) {
error_page (
tra ( " This thread has been hidden for administrative purposes " )
);
2006-12-30 18:35:25 +00:00
}
}
2007-11-12 20:57:15 +00:00
$title = cleanup_title ( $thread -> title );
2006-06-16 23:53:56 +00:00
if ( ! $sort_style ) {
// get the sorting style from the user or a cookie
if ( $logged_in_user ){
2007-11-12 20:57:15 +00:00
$sort_style = $logged_in_user -> prefs -> thread_sorting ;
2005-01-09 09:33:06 +00:00
} else {
2006-06-16 23:53:56 +00:00
list ( $forum_style , $sort_style ) = explode ( " | " , $_COOKIE [ 'sorting' ]);
2005-01-09 09:33:06 +00:00
}
2003-08-01 20:30:25 +00:00
} else {
2006-06-16 23:53:56 +00:00
if ( $logged_in_user ){
2007-11-12 20:57:15 +00:00
$logged_in_user -> prefs -> thread_sorting = $sort_style ;
$logged_in_user -> prefs -> update ( " thread_sorting= $sort_style " );
2005-01-09 09:33:06 +00:00
} else {
2006-06-16 23:53:56 +00:00
list ( $forum_style , $old_style ) = explode ( " | " , $_COOKIE [ 'sorting' ]);
2008-02-13 19:02:44 +00:00
send_cookie ( 'sorting' , implode ( " | " , array ( $forum_style , $sort_style )), true );
2007-05-13 18:41:34 +00:00
}
2003-07-26 00:19:41 +00:00
}
2003-08-13 22:08:12 +00:00
2007-11-12 20:57:15 +00:00
if ( $logged_in_user && $logged_in_user -> prefs -> jump_to_unread ){
2006-06-16 23:53:56 +00:00
page_head ( $title , 'jumpToUnread();' );
2003-08-13 22:08:12 +00:00
} else {
2006-06-16 23:53:56 +00:00
page_head ( $title );
2006-04-26 07:41:25 +00:00
}
2008-12-13 20:04:01 +00:00
echo " <link href= \" forum_forum.php?id= " . $forum -> id . " \" rel= \" up \" title= \" " . $forum -> title . " \" > " ;
2005-02-13 21:33:02 +00:00
2007-11-12 20:57:15 +00:00
$is_subscribed = $logged_in_user && BoincSubscription :: lookup ( $logged_in_user -> id , $thread -> id );
2006-06-16 23:53:56 +00:00
2007-11-15 00:27:02 +00:00
show_forum_header ( $logged_in_user );
2007-11-16 21:48:28 +00:00
2008-08-07 20:43:52 +00:00
echo " <p> " ;
2007-11-16 21:48:28 +00:00
switch ( $forum -> parent_type ) {
case 0 :
2007-11-15 22:51:05 +00:00
$category = BoincCategory :: lookup_id ( $forum -> category );
show_forum_title ( $category , $forum , $thread );
2007-11-16 21:48:28 +00:00
break ;
case 1 :
2007-11-26 04:12:15 +00:00
show_team_forum_title ( $forum , $thread );
2007-11-16 21:48:28 +00:00
break ;
}
2006-12-30 18:35:25 +00:00
2007-11-16 21:48:28 +00:00
if ( $forum -> parent_type == 0 ) {
2007-11-15 22:51:05 +00:00
if ( $category -> is_helpdesk && ! $thread -> status ){
if ( $logged_in_user ){
2007-11-12 20:57:15 +00:00
if ( $thread -> owner == $logged_in_user -> id ){
if ( $thread -> replies != 0 ) {
2007-05-13 18:41:34 +00:00
// Show a "this question has been answered" to the author
echo " <div class= \" helpdesk_note \" >
2007-11-12 20:57:15 +00:00
< form action = \ " forum_thread_status.php \" ><input type= \" hidden \" name= \" id \" value= \" " . $thread -> id . " \" >
2008-12-13 20:04:01 +00:00
< input type = \ " submit \" value= \" " . tra ( " My question was answered " ) . " \" >
2007-05-13 18:41:34 +00:00
</ form >
2008-12-13 20:04:01 +00:00
" . tra( " If your question has been adequately answered please click here to close it ! " ) . "
2007-05-13 18:41:34 +00:00
</ div > " ;
}
} else {
// and a "I also got this question" to everyone else if they havent already told so
echo " <div class= \" helpdesk_note \" >
2007-11-12 20:57:15 +00:00
< form action = \ " forum_thread_vote.php \" ><input type= \" hidden \" name= \" id \" value= \" " . $thread -> id . " \" >
2008-12-13 20:04:01 +00:00
< input type = \ " submit \" value= \" " . tra ( " I've also got this question " ) . " \" >
2007-05-13 18:41:34 +00:00
</ form >
</ div > " ;
}
}
2007-01-03 18:07:44 +00:00
}
2007-11-15 22:51:05 +00:00
}
echo "
2007-11-20 19:23:26 +00:00
< p >
2008-09-25 10:48:49 +00:00
< form action = \ " forum_thread.php \" >
2007-11-15 22:51:05 +00:00
< table width = \ " 100% \" cellspacing=0 cellpadding=0>
2008-09-25 10:48:49 +00:00
< tr class = \ " forum_toplinks \" >
2008-09-27 10:08:16 +00:00
< td >< ul class = \ " actionlist \" >
2007-11-15 22:51:05 +00:00
" ;
$reply_url = " " ;
2007-11-16 20:52:42 +00:00
if ( can_reply ( $thread , $forum , $logged_in_user )) {
2007-11-15 22:51:05 +00:00
$reply_url = " forum_reply.php?thread= " . $thread -> id . " #input " ;
2008-12-13 20:04:01 +00:00
show_actionlist_button ( $reply_url , tra ( " Post to thread " ), tra ( " Add a new message to this thread " ));
2007-11-15 22:51:05 +00:00
}
if ( $is_subscribed ) {
2007-12-30 22:02:16 +00:00
$type = NOTIFY_SUBSCRIBED_POST ;
BoincNotify :: delete_aux ( " userid= $logged_in_user->id and type= $type and opaque= $thread->id " );
2007-11-15 22:51:05 +00:00
$url = " forum_subscribe.php?action=unsubscribe&thread= " . $thread -> id . " $tokens " ;
2008-12-13 20:04:01 +00:00
show_actionlist_button ( $url , tra ( " Unsubscribe " ), tra ( " You are subscribed to this thread. Click here to unsubscribe. " ));
2007-11-15 22:51:05 +00:00
} else {
$url = " forum_subscribe.php?action=subscribe&thread= " . $thread -> id . " $tokens " ;
2008-12-13 20:04:01 +00:00
show_actionlist_button ( $url , tra ( " Subscribe " ), tra ( " Click to get email when there are new posts in this thread " ));
2007-11-15 22:51:05 +00:00
}
//If the logged in user is moderator enable some extra features
//
if ( is_moderator ( $logged_in_user , $forum )) {
if ( $thread -> hidden ){
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread_action.php?action=unhide&thread= " . $thread -> id . " $tokens " , tra ( " Unhide " ), tra ( " Unhide this thread " ));
2007-11-15 22:51:05 +00:00
} else {
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread.php?action=hide&thread= " . $thread -> id , tra ( " Hide " ), tra ( " Hide this thread " ));
2005-02-13 21:33:02 +00:00
}
2007-11-15 22:51:05 +00:00
if ( $thread -> sticky ){
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread_action.php?action=desticky&thread= " . $thread -> id . " $tokens " , tra ( " Make unsticky " ), tra ( " Make this thread not sticky " ));
2006-12-30 18:35:25 +00:00
} else {
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread_action.php?action=sticky&thread= " . $thread -> id . " $tokens " , tra ( " Make sticky " ), tra ( " Make this thread sticky " ));
2006-06-16 23:53:56 +00:00
}
2007-11-15 22:51:05 +00:00
if ( $thread -> locked ) {
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread_action.php?action=unlock&thread= " . $thread -> id . " $tokens " , tra ( " Unlock " ), tra ( " Unlock this thread " ));
2007-11-15 22:51:05 +00:00
} else {
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread.php?action=lock&thread= " . $thread -> id . " $tokens " , tra ( " Lock " ), tra ( " Lock this thread " ));
2007-11-15 22:51:05 +00:00
}
if ( $forum -> parent_type == 0 ) {
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread.php?action=move&thread= " . $thread -> id . " $tokens " , tra ( " Move " ), tra ( " Move this thread to a different forum " ));
2006-12-30 18:35:25 +00:00
}
2008-12-13 20:04:01 +00:00
show_actionlist_button ( " forum_moderate_thread.php?action=title&thread= " . $thread -> id . " $tokens " , tra ( " Edit title " ), tra ( " Edit thread title " ));
2007-11-15 22:51:05 +00:00
}
2008-09-27 09:52:28 +00:00
echo " </ul> " ; //End of action list
2005-02-13 21:33:02 +00:00
2007-11-15 22:51:05 +00:00
// Display a box that allows the user to select sorting of the posts
2008-09-25 10:48:49 +00:00
echo " </td><td align= \" right \" >
2008-12-13 20:04:01 +00:00
< input type = \ " hidden \" name= \" id \" value= \" " , $thread -> id , " \" > " .
tra ( " Sort " );
2007-11-15 22:51:05 +00:00
echo select_from_array ( " sort " , $thread_sort_styles , $sort_style );
2008-12-13 20:04:01 +00:00
echo " <input type= \" submit \" value= \" Sort \" >
2008-09-25 10:48:49 +00:00
</ td ></ tr ></ table ></ form >
2007-11-15 22:51:05 +00:00
" ;
// Here is where the actual thread begins.
2008-08-07 20:43:52 +00:00
$headings = array ( array ( tra ( " Author " ), " authorcol " ), array ( tra ( " Message " ), " " ));
2007-11-15 22:51:05 +00:00
start_forum_table ( $headings , " id= \" thread \" width=100% " );
show_posts ( $thread , $forum , $sort_style , $filter , $logged_in_user , true );
end_table ();
if ( $reply_url ) {
2008-12-13 20:04:01 +00:00
show_button ( $reply_url , tra ( " Post to thread " ), tra ( " Add a new message to this thread " ));
2007-11-15 22:51:05 +00:00
}
2007-11-20 19:23:26 +00:00
echo " <p> " ;
2007-11-16 21:48:28 +00:00
switch ( $forum -> parent_type ) {
case 0 :
2007-11-15 00:27:02 +00:00
show_forum_title ( $category , $forum , $thread );
2007-11-16 21:48:28 +00:00
break ;
case 1 :
2007-11-26 04:12:15 +00:00
show_team_forum_title ( $forum , $thread );
2007-11-16 21:48:28 +00:00
break ;
2007-11-15 22:51:05 +00:00
}
$thread -> update ( " views=views+1 " );
2003-08-13 22:08:12 +00:00
2003-08-15 01:01:00 +00:00
page_tail ();
2007-11-12 20:57:15 +00:00
$cvs_version_tracker [] = " \$ Id $ " ;
2003-07-21 22:02:20 +00:00
?>