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 ){
$sort_style = $user -> getForumSortStyle ();
2004-01-19 01:12:53 +00:00
} else {
2006-06-16 23:53:56 +00:00
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 ){
$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 ){
page_head ( tr ( LINKS_QA ) . ' : ' . $forum -> getTitle ());
} else {
page_head ( tr ( FORUM_TITLE_SHORT ) . ' : ' . $forum -> getTitle ());
}
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
2006-06-16 23:53:56 +00:00
echo '
< table width = " 100% " cellspacing = " 0 " cellpadding = " 0 " >
< tr valign = " bottom " >
< td colspan = 2 > ' ;
2003-08-13 22:08:12 +00:00
2006-06-16 23:53:56 +00:00
show_forum_title ( $forum , NULL );
2003-08-13 22:08:12 +00:00
2006-06-16 23:53:56 +00:00
if ( $Category -> getType () != 0 ){
echo "
< div class = \ " helpdesk_note \" >
< br />< form action = \ " forum_search.php \" ><input type= \" hidden \" name= \" forumid \" value= \" " . $forum -> getID () . " \" ><input type= \" submit \" value= \" Search " . $forum -> getTitle () . " \" ></form>
To keep the number of repeated posts to a minimum please < a href = \ " forum_search.php \" ><b><font color= \" green \" >search</font></b></a> before you create a new thread.
</ div ></ td ></ tr >< tr >< td > " ;
2003-08-13 22:08:12 +00:00
}
2006-08-09 19:12:54 +00:00
echo '<a href="forum_post.php?id=' . $id . '">' ;
echo " [Create a new thread]</a><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">' ;
show_select_from_array ( " sort " , $forum_sort_styles , $sort_style );
2006-08-09 19:12:54 +00:00
echo '<input type="submit" value="OK"><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
start_forum_table ( array ( " " , tr ( FORUM_THREADS ), tr ( FORUM_POSTS ), tr ( FORUM_AUTHOR ), tr ( FORUM_VIEWS ), " <nobr> " . tr ( FORUM_LAST_POST ) . " </nobr> " ));
$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 );
// Run through the list of threads, displaying each of them
$n = 0 ; $i = 0 ;
foreach ( $threads as $key => $thread ) {
$owner = $thread -> getOwner ();
$unread = $user && ( $thread -> getLastTimestamp () > $thread -> getLastReadTimestamp ( $user ));
if ( $thread -> getStatus () == 1 ){
// This is an answered helpdesk thread
echo '<tr class="row_hd' . $n . '">' ;
} else {
// Just a standard thread.
echo '<tr class="row' . $n . '">' ;
}
echo " <td width= \" 1% \" align= \" right \" ><nobr> " ;
if ( $user && ( $thread -> getRating () > $user -> getHighRatingThreshold ())) {
echo " <img src= \" " . EMPHASIZE_IMAGE . " \" alt= \" Emphasized thread \" > " ;
}
if ( $user && ( $thread -> getRating () < $user -> getLowRatingThreshold ())) {
echo " <img src= \" " . FILTER_IMAGE . " \" alt= \" Filtered thread \" > " ;
}
if ( $thread -> isHidden ()) {
echo " X " ;
}
if ( $unread && ! $thread -> isSticky ()) {
echo " <img src= \" " . NEW_IMAGE . " \" alt= \" Unread post(s) \" > " ;
}
elseif ( $unread ) {
echo " <img src= \" " . NEW_IMAGE_STICKY . " \" alt= \" Unread post(s) \" > " ;
}
elseif ( $thread -> isSticky ()) {
echo " <img src= \" " . STICKY_IMAGE . " \" alt= \" Sticky \" > " ;
}
echo " </nobr></td> " ;
$titlelength = 48 ;
$title = cleanup_title ( $thread -> getTitle ());
if ( strlen ( $title ) > $titlelength ) {
$title = substr ( $title , 0 , $titlelength ) . " ... " ;
}
echo '<td class="threadline"><a href="forum_thread.php?id=' . $thread -> getID () . '"><b>' . $title . '</b></a><br></td>' ;
$n = ( $n + 1 ) % 2 ;
echo '
< 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 ();
}
end_forum_table ();
echo $gotoStr ; // Display the navigation bar at the bottom as well.
}
2003-11-30 21:05:57 +00:00
?>