2004-02-02 23:34:39 +00:00
< ? php
2007-11-12 20:57:15 +00:00
require_once ( " ../inc/forum_db.inc " );
require_once ( " ../inc/pm.inc " );
2007-11-15 22:51:05 +00:00
require_once ( " ../inc/team.inc " );
2007-11-12 20:57:15 +00:00
require_once ( " ../inc/text_transform.inc " );
define ( 'THREADS_PER_PAGE' , 50 );
// sorting styles
define ( 'MODIFIED_NEW' , 1 );
define ( 'MODIFIED_OLD' , 2 );
define ( 'VIEWS_MOST' , 3 );
define ( 'REPLIES_MOST' , 4 );
define ( 'CREATE_TIME_NEW' , 5 );
define ( 'CREATE_TIME_OLD' , 6 );
define ( 'POST_SCORE' , 7 );
// names for the above
$thread_sort_styles [ CREATE_TIME_OLD ] = " Least recent post first " ;
$thread_sort_styles [ CREATE_TIME_NEW ] = " Most recent post first " ;
$thread_sort_styles [ POST_SCORE ] = " Highest rated posts first " ;
$forum_sort_styles [ MODIFIED_NEW ] = " Most recent reply first " ;
//$forum_sort_styles[MODIFIED_OLD] = "Least recent reply first";
$forum_sort_styles [ VIEWS_MOST ] = " Most views first " ;
$forum_sort_styles [ REPLIES_MOST ] = " Most posts first " ;
$forum_sort_styles [ CREATE_TIME_NEW ] = " Most recently created first " ;
//$forum_sort_styles[CREATE_TIME_OLD] = "Least recently created first";
// values for thread.status
define ( 'THREAD_SOLVED' , 1 );
2004-02-02 23:34:39 +00:00
2004-09-04 23:37:49 +00:00
define ( 'AVATAR_WIDTH' , 100 );
define ( 'AVATAR_HEIGHT' , 100 );
2005-01-18 13:00:38 +00:00
2004-09-04 23:37:49 +00:00
define ( 'ST_NEW_TIME' , 1209600 ); //3600*24*14 - 14 days
define ( 'ST_NEW' , 'New member' );
2007-11-12 20:57:15 +00:00
define ( 'MAXIMUM_EDIT_TIME' , 3600 );
// allow edits of forums posts up till one hour after posting.
2004-09-04 23:37:49 +00:00
2006-06-16 23:53:56 +00:00
define ( 'MAX_FORUM_LOGGING_TIME' , 2419200 ); //3600*24*28 - 28 days
2004-02-02 23:34:39 +00:00
define ( 'NO_CONTROLS' , 0 );
define ( 'FORUM_CONTROLS' , 1 );
define ( 'HELPDESK_CONTROLS' , 2 );
define ( " EXCERPT_LENGTH " , " 120 " );
2005-04-20 20:56:58 +00:00
define ( 'NEW_IMAGE' , 'img/unread_post.png' );
define ( 'NEW_IMAGE_STICKY' , 'img/unread_sticky.png' );
2006-11-10 17:09:09 +00:00
define ( 'NEW_IMAGE_LOCKED' , 'img/unread_locked.png' );
define ( 'NEW_IMAGE_STICKY_LOCKED' , 'img/unread_sticky_locked.png' );
define ( 'IMAGE_STICKY' , 'img/sticky_post.png' );
define ( 'IMAGE_LOCKED' , 'img/locked_post.png' );
define ( 'IMAGE_STICKY_LOCKED' , 'img/sticky_locked_post.png' );
2004-10-10 03:04:29 +00:00
define ( 'NEW_IMAGE_HEIGHT' , '15' );
2005-04-20 20:56:58 +00:00
define ( 'EMPHASIZE_IMAGE' , 'img/emphasized_post.png' );
2004-10-25 22:04:15 +00:00
define ( 'EMPHASIZE_IMAGE_HEIGHT' , '15' );
2005-04-20 20:56:58 +00:00
define ( 'FILTER_IMAGE' , 'img/filtered_post.png' );
2004-12-18 18:13:46 +00:00
define ( 'FILTER_IMAGE_HEIGHT' , '15' );
2005-04-30 09:04:00 +00:00
define ( 'RATE_POSITIVE_IMAGE' , 'img/rate_positive.png' );
define ( 'RATE_POSITIVE_IMAGE_HEIGHT' , '9' );
define ( 'RATE_NEGATIVE_IMAGE' , 'img/rate_negative.png' );
define ( 'RATE_NEGATIVE_IMAGE_HEIGHT' , '9' );
2005-10-01 11:11:53 +00:00
define ( 'REPORT_POST_IMAGE' , 'img/report_post.png' );
define ( 'REPORT_POST_IMAGE_HEIGHT' , '9' );
2004-02-02 23:34:39 +00:00
define ( 'SOLUTION' , 'This answered my question' );
define ( 'SUFFERER' , 'I also have this question' );
define ( 'OFF_TOPIC' , 'Off-topic' );
2004-10-25 22:04:15 +00:00
define ( 'DEFAULT_LOW_RATING_THRESHOLD' , - 25 );
define ( 'DEFAULT_HIGH_RATING_THRESHOLD' , 5 );
2007-11-12 20:57:15 +00:00
// A list of what kind of special users exist
define ( 'S_MODERATOR' , 0 );
define ( 'S_ADMIN' , 1 );
define ( 'S_DEV' , 2 );
define ( 'S_TESTER' , 3 );
define ( 'S_VOLUNTEER' , 4 );
define ( 'S_VOLUNTEER_TESTER' , 5 );
define ( 'S_SCIENTIST' , 6 );
$special_user_bitfield [ S_MODERATOR ] = " Forum moderator " ;
$special_user_bitfield [ S_ADMIN ] = " Project administrator " ;
$special_user_bitfield [ S_DEV ] = " Project developer " ;
$special_user_bitfield [ S_TESTER ] = " Project tester " ;
$special_user_bitfield [ S_VOLUNTEER ] = " Volunteer developer " ;
$special_user_bitfield [ S_VOLUNTEER_TESTER ] = " Volunteer tester " ;
$special_user_bitfield [ S_SCIENTIST ] = " Project scientist " ;
2007-11-15 00:27:02 +00:00
// show a banner with search form on left and PM info on right
//
function show_forum_header ( $user ) {
start_table_noborder ();
echo " <tr> \n " ;
// Search
echo " <td><form action= \" forum_search_action.php \" method= \" POST \" >
< input type = \ " hidden \" name= \" search_max_time \" value= \" 30 \" >
< input type = \ " hidden \" name= \" search_forum \" value= \" -1 \" >
< input type = \ " hidden \" name= \" search_sort \" value= \" 5 \" >
< input type = \ " text \" name= \" search_keywords \" >
< input class = \ " btn \" title= \" Search for words in forum messages \" type= \" submit \" value= \" Search forums \" ><br>
< span class = \ " smalltext \" ><a href= \" forum_search.php \" >Advanced search</a></span>
</ form >
" ;
echo " </td> \n " ;
if ( $user ) {
echo " <td align= \" right \" > \n " ;
2007-11-19 16:44:24 +00:00
echo " <p>Private messages: " , pm_notification ( $user );
2007-11-12 20:57:15 +00:00
echo " </td> \n " ;
}
2007-11-15 00:27:02 +00:00
echo " </tr> \n " ;
end_table ();
}
2004-09-04 23:37:49 +00:00
2007-11-15 00:27:02 +00:00
// Output the forum/thread title.
//
function show_forum_title ( $category , $forum , $thread ) {
2007-11-12 20:57:15 +00:00
if ( $category ) {
$is_helpdesk = $category -> is_helpdesk ;
} else {
$is_helpdesk = false ;
}
$where = $is_helpdesk ? tra ( " Questions and Answers " ) : tra ( " Message boards " );
$top_url = $is_helpdesk ? " forum_help_desk.php " : " forum_index.php " ;
if ( ! $forum && ! $thread ) {
2007-11-20 19:23:26 +00:00
echo " <span class= \" title \" > $where </span> " ;
2004-02-02 23:34:39 +00:00
2007-11-12 20:57:15 +00:00
} else if ( $forum && ! $thread ) {
echo " <span class=title> " ;
echo " <a href= \" $top_url\ " > $where </ a > : " ;
echo $forum -> title ;
2007-11-20 19:23:26 +00:00
echo " </span> " ;
2007-11-12 20:57:15 +00:00
} else if ( $forum && $thread ) {
echo " <span class=title> " ;
echo " <a href= \" $top_url\ " > $where </ a > : " ;
2004-02-02 23:34:39 +00:00
2007-11-12 20:57:15 +00:00
echo " <a href= \" forum_forum.php?id= " . $forum -> id . " \" > " , $forum -> title , " </a> : " ;
echo cleanup_title ( $thread -> title );
2007-11-20 19:23:26 +00:00
echo " </span> " ;
2007-11-12 20:57:15 +00:00
} else {
2007-11-20 19:23:26 +00:00
echo " Invalid input to show_forum_title<br> " ;
echo " threadid $thread->id " ;
// TODO: handle this condition gracefully
2007-11-12 20:57:15 +00:00
}
}
2004-02-02 23:34:39 +00:00
2007-11-20 19:23:26 +00:00
function show_team_forum_title ( $forum , $thread = null ) {
2007-11-16 21:48:28 +00:00
$team = BoincTeam :: lookup_id ( $forum -> category );
2007-11-20 19:23:26 +00:00
echo " <a href=team_forum.php?teamid= $team->id ><span class=title> $team->name message board</span></a>
2007-11-16 21:48:28 +00:00
" ;
2007-11-20 19:23:26 +00:00
if ( $thread ) {
echo " : <a href=forum_thread.php?id= $thread->id > $thread->title </a> " ;
}
2007-11-16 21:48:28 +00:00
}
2007-11-12 20:57:15 +00:00
// Start the forum table, output the proper headings and such.
//
function start_forum_table ( $headings , $extra = " width= \" 100% \" " ) {
$span = null ;
start_table ( $extra . " cellspacing= \" 0 \" " );
echo " <tr> " ;
2004-02-02 23:34:39 +00:00
2007-11-12 20:57:15 +00:00
for ( $i = 0 ; $i < count ( $headings ); $i ++ ) {
if ( is_array ( $headings [ $i ])){
$title = $headings [ $i ][ 0 ];
$class = $headings [ $i ][ 1 ] ? $headings [ $i ][ 1 ] : " heading " ;
if ( isset ( $headings [ $i ][ 2 ])) {
$span = " colspan= \" " . $headings [ $i ][ 2 ] . " \" " ;
}
} else {
$title = $headings [ $i ];
$class = " heading " ;
$span = " " ;
}
echo " <th class= $class $span > $title </th> " ;
}
echo " </tr> \n " ;
}
// return a string containing a paged navigation bar
// for the given forum. The default start place is 0.
//
function show_page_nav ( $forum , $start = 0 ){
// How many pages to potentially show before and after this one:
$preshow = 5 ; $postshow = 10 ;
$navbar = " " ;
if ( $forum -> threads > THREADS_PER_PAGE ) {
$total = ceil ( $forum -> threads / THREADS_PER_PAGE );
$curpage = ceil ( $start / THREADS_PER_PAGE );
// If this is not the first page, display "previous"
if ( $curpage > 0 ){
$navbar = '<a href="forum_forum.php?id=' . get_int ( " id " ) . '&start=' . (( $curpage - 1 ) * THREADS_PER_PAGE );
$sort = get_int ( " sort " , true );
if ( $sort ) $navbar .= '&sort=' . $sort ;
$navbar .= '"> <-- Previous</a> ' ;
}
// Display a list of pages surrounding this one
for ( $i = $curpage - $preshow ; $i < ( $curpage + $postshow ); $i ++ ){
if ( $i < 1 ) continue ;
if ( $i > $total ) break ;
// If this is the current page, emphasize it.
if ( $i == $curpage + 1 ){
$navbar .= " <em> " ;
}
$navbar .= '<a href="forum_forum.php?id=' . get_int ( " id " ) . '&start=' . (( $i - 1 ) * THREADS_PER_PAGE );
$sort = get_int ( " sort " , true );
if ( $sort ) $navbar .= '&sort=' . $sort ;
$navbar .= '">' . $i . ' |</a> ' ;
if ( $i == $curpage + 1 ){ $navbar .= " </em> " ;}
}
// If there is a next page
if ( $curpage + 1 < $total ){
$navbar .= '<a href="forum_forum.php?id=' . get_int ( " id " ) . '&start=' . (( $curpage + 1 ) * THREADS_PER_PAGE );
$sort = get_int ( " sort " , true );
if ( $sort ) $navbar .= '&sort=' . $sort ;
$navbar .= '"> Next --></a>' ;
}
}
return $navbar ;
}
function thread_last_visit ( $user , $thread ) {
if ( ! $user ) return false ;
$log = BoincForumLogging :: lookup ( $user -> id , $thread -> id );
return $log -> timestamp ;
}
2006-07-10 17:18:42 +00:00
2007-11-12 20:57:15 +00:00
function thread_is_unread ( $user , $thread ) {
if ( ! $user ) return false ;
$log = BoincForumLogging :: lookup ( $user -> id , $thread -> id );
if ( $thread -> timestamp < $log -> timestamp ) return false ;
if ( $thread -> timestamp < $user -> prefs -> mark_as_read_timestamp ) return false ;
return true ;
}
// Process a user-supplied title to remove HTML stuff
//
2005-01-09 21:52:22 +00:00
function cleanup_title ( $title ) {
2006-12-23 14:59:47 +00:00
$x = trim ( htmlspecialchars ( $title ));
2005-01-14 19:45:43 +00:00
$x = stripslashes ( $x ); // clean up funky old titles in DB
2005-01-09 21:52:22 +00:00
if ( strlen ( $x ) == 0 ) return " (no title) " ;
else return $x ;
}
2007-11-15 22:51:05 +00:00
function can_reply ( $thread , $forum , $user ) {
if ( $thread -> locked ) {
if ( ! is_moderator ( $user , $forum )) return false ;
2004-09-05 19:26:27 +00:00
}
2007-11-15 22:51:05 +00:00
return true ;
2004-09-04 23:37:49 +00:00
}
2007-11-12 20:57:15 +00:00
function should_show_post (
$logged_in_user , $postcount , $postnumber , $post , $sort_style , $last_visit
){
2007-11-11 19:22:35 +00:00
$no_wraparound = get_str ( " nowrap " , true );
2004-03-26 22:56:45 +00:00
2007-11-12 20:57:15 +00:00
// If no user logged in, display everything (useful for Google bots etc)
//
2007-11-11 19:22:35 +00:00
if ( ! $logged_in_user ) return true ;
2007-11-12 20:57:15 +00:00
// If the user hasn't enabled the feature to display only
// a certain amount of posts, simply display all of them.
//
if ( ! $logged_in_user -> prefs -> minimum_wrap_postcount ) return true ;
2007-11-11 19:22:35 +00:00
// If the user has asked to display all the posts just display them
2007-11-12 20:57:15 +00:00
//
2007-11-11 19:22:35 +00:00
if ( $no_wraparound ) return true ;
// If it is enabled and we havent yet hit the limit, simply display all
2007-11-12 20:57:15 +00:00
if ( $postcount < $logged_in_user -> prefs -> minimum_wrap_postcount ) return true ;
2007-11-11 19:22:35 +00:00
2007-11-12 20:57:15 +00:00
// display the post if it is the first post
//
2007-11-11 19:22:35 +00:00
if ( $postnumber == 1 || $postnumber == ( $postcount + 1 )) return true ;
2007-11-12 20:57:15 +00:00
// if this post is unread, show it
//
if ( $post -> timestamp > $last_visit ) return true ;
2007-11-11 19:22:35 +00:00
2007-11-12 20:57:15 +00:00
// The user can choose to display the last X posts in a thread only,
// "last" here depends on sorting criteria:
//
2007-11-11 19:22:35 +00:00
if ( $sort_style == CREATE_TIME_OLD ){
2007-11-12 20:57:15 +00:00
if ( $postnumber > $postcount + 1 - $logged_in_user -> prefs -> display_wrap_postcount ) return true ;
2007-11-11 19:22:35 +00:00
} else if ( CREATE_TIME_NEW ){
2007-11-12 20:57:15 +00:00
if ( $postnumber <= $logged_in_user -> prefs -> display_wrap_postcount ) return true ;
2007-11-11 19:22:35 +00:00
} else {
2007-11-12 20:57:15 +00:00
// For other sorting criteria we do not know how to define "last"
// so simply display it all
//
return true ;
2007-11-11 19:22:35 +00:00
}
// In all other cases we should not show this particular post
return false ;
}
2004-02-02 23:34:39 +00:00
2007-11-12 20:57:15 +00:00
// Show the posts in a thread for a user.
//
2007-10-30 23:34:26 +00:00
function show_posts (
2007-11-15 22:51:05 +00:00
$thread , $forum , $sort_style , $filter , $logged_in_user , $show_controls = true
2007-10-30 23:34:26 +00:00
) {
2004-02-02 23:34:39 +00:00
$n = 1 ;
2007-10-12 17:58:50 +00:00
$first_unread_post = null ;
2007-10-30 23:34:26 +00:00
$last_visit = 0 ;
2007-10-12 17:58:50 +00:00
2006-06-16 23:53:56 +00:00
if ( $show_controls ) {
2004-02-02 23:34:39 +00:00
$controls = FORUM_CONTROLS ;
} else {
$controls = NO_CONTROLS ;
}
2005-09-20 17:54:52 +00:00
// If logged in user is moderator,
// let him see all posts - including hidden ones
2007-11-15 22:51:05 +00:00
//
if ( is_moderator ( $logged_in_user , $forum )) {
$show_hidden = true ;
2005-01-18 13:00:38 +00:00
} else {
2007-11-15 22:51:05 +00:00
$show_hidden = false ;
2005-01-18 13:00:38 +00:00
}
2007-11-15 22:51:05 +00:00
$posts = get_thread_posts ( $thread -> id , $sort_style , $show_hidden );
2006-06-16 23:53:56 +00:00
$postcount = ( sizeof ( $posts ) - 1 );
2007-10-30 23:34:26 +00:00
if ( $logged_in_user ) {
2007-11-12 20:57:15 +00:00
$last_visit = thread_last_visit ( $logged_in_user , $thread );
2007-10-30 23:34:26 +00:00
}
2004-02-02 23:34:39 +00:00
2005-11-28 00:24:32 +00:00
$postnumber = 0 ; $previous_post = 0 ;
2007-11-12 20:57:15 +00:00
$no_wraparound = get_str ( " nowrap " , true );
foreach ( $posts as $post ){
$postnumber ++ ;
if ( should_show_post (
$logged_in_user , $postcount , $postnumber , $post ,
$sort_style , $last_visit )
) {
2007-10-30 23:34:26 +00:00
if ( $postnumber != $previous_post + 1 ){
2007-11-12 20:57:15 +00:00
// A number of posts were hidden, display a way to unhide them:
//
2007-10-30 23:34:26 +00:00
echo " <tr class= \" postseperator \" ><td></td><td colspan= \" 2 \" >
2007-11-12 20:57:15 +00:00
Only the first post and the last " .( $logged_in_user->prefs ->display_wrap_postcount). " posts
( of the " .( $postcount +1). " posts in this thread ) are displayed . < br />
< a href = \ " ?id= " . $thread -> id . " &nowrap=true \" >Click here to also display the remaining posts</a>.</td></tr>
" ;
2006-06-16 23:53:56 +00:00
}
2007-10-30 23:34:26 +00:00
$previous_post = $postnumber ;
2007-11-15 22:51:05 +00:00
show_post ( $post , $thread , $forum , $logged_in_user , $last_visit , $n , $controls , $filter );
2007-10-30 23:34:26 +00:00
$n = ( $n + 1 ) % 2 ;
2007-11-12 20:57:15 +00:00
if (( $post -> timestamp > $last_visit ) &&
(( ! $first_unread_post ) || ( $post -> timestamp < $first_unread_post -> timestamp ))
2007-10-30 23:34:26 +00:00
){
$first_unread_post = $post ;
}
}
2004-02-02 23:34:39 +00:00
}
2005-01-09 21:52:22 +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
if ( $first_unread_post ){
2007-11-12 20:57:15 +00:00
echo " <script>function jumpToUnread() { location.href='# " . $first_unread_post -> id . " ';}</script> " ;
2004-10-10 03:04:29 +00:00
} else {
echo " <script>function jumpToUnread() { };</script> " ;
}
}
2006-06-16 23:53:56 +00:00
2007-11-12 20:57:15 +00:00
if ( $logged_in_user ) {
BoincForumLogging :: replace ( $logged_in_user -> id , $thread -> id , time ());
}
2004-02-02 23:34:39 +00:00
}
2007-11-13 17:18:34 +00:00
function get_ignored_list ( $user ) {
return explode ( " | " , $user -> prefs -> ignorelist );
}
2007-11-12 20:57:15 +00:00
function add_ignored_user ( $user , $other_user ) {
$list = explode ( " | " , $user -> prefs -> ignorelist );
foreach ( $list as $key => $userid ) {
if ( $userid == $other_user -> id ) {
return true ;
}
}
$list [] = $other_user -> id ;
$x = implode ( " | " , array_values ( $list ));
return $user -> prefs -> update ( " ignorelist=' $x ' " );
}
function remove_ignored_user ( $user , $other_user ) {
$list = explode ( " | " , $user -> prefs -> ignorelist );
foreach ( $list as $key => $userid ) {
if ( $userid == $other_user -> id ) {
unset ( $list [ $key ]);
}
}
$x = implode ( " | " , array_values ( $list ));
return $user -> prefs -> update ( " ignorelist=' $x ' " );
}
function is_ignoring ( $user , $other_user ) {
$list = explode ( " | " , $user -> prefs -> ignorelist );
return in_array ( $other_user -> id , $list );
}
function get_output_options ( $user ) {
2007-11-20 19:23:26 +00:00
if ( ! $user ) return null ;
2007-11-12 20:57:15 +00:00
$options = new output_options ();
if ( $user -> prefs -> images_as_links ) $options -> images_as_links = 1 ;
if ( $user -> prefs -> link_popup ) $options -> link_popup = 1 ;
return $options ;
}
// Display an individual post
//
function show_post (
2007-11-15 22:51:05 +00:00
$post , $thread , $forum , $logged_in_user , $last_visit , $n , $controls = FORUM_CONTROLS , $filter = true
2007-11-12 20:57:15 +00:00
) {
$user = BoincUser :: lookup_id ( $post -> user );
BoincForumPrefs :: lookup ( $user );
$config = get_config ();
$no_forum_rating = parse_bool ( $config , " no_forum_rating " );
2006-06-16 23:53:56 +00:00
2007-10-30 23:34:26 +00:00
$tokens = " " ;
$rated_below_threshold = false ;
$rated_above_threshold = false ;
2007-11-20 19:23:26 +00:00
$options = get_output_options ( $logged_in_user );
2007-02-08 19:54:05 +00:00
2007-10-30 23:34:26 +00:00
//If the user that made this post is on the list of people to ignore,
// change thresholds to be much more strict
//
2006-06-16 23:53:56 +00:00
if ( $logged_in_user ){
2007-11-12 20:57:15 +00:00
$tokens = url_tokens ( $logged_in_user -> authenticator );
if ( is_ignoring ( $logged_in_user , $user )){
2006-06-16 23:53:56 +00:00
$user_is_on_ignorelist = true ;
2007-11-12 20:57:15 +00:00
$rated_below_threshold = ( $logged_in_user -> prefs -> high_rating_threshold > $post -> rating ());
$rated_above_threshold = ( $logged_in_user -> prefs -> high_rating_threshold + abs ( $logged_in_user -> prefs -> low_rating_threshold ) < ( $post -> rating ));
2006-06-16 23:53:56 +00:00
} else { //Use normal threshold values
2007-11-12 20:57:15 +00:00
$rated_below_threshold = ( $logged_in_user -> prefs -> low_rating_threshold > ( $post -> rating ()));
$rated_above_threshold = ( $logged_in_user -> prefs -> high_rating_threshold < ( $post -> rating ));
2006-06-16 23:53:56 +00:00
}
2005-01-06 11:47:44 +00:00
}
2007-10-30 23:34:26 +00:00
2006-08-01 22:28:03 +00:00
// The creator can edit the post, but only in a specified amount of time
// (exception: a moderator can edit his/her posts at any time)
2006-08-01 21:45:05 +00:00
//
2006-08-01 22:28:03 +00:00
$can_edit = false ;
if ( $logged_in_user ) {
2007-11-12 20:57:15 +00:00
if ( $user -> id == $logged_in_user -> id ) {
2007-11-15 22:51:05 +00:00
if ( is_moderator ( $logged_in_user , $forum )) {
2006-08-01 22:28:03 +00:00
$can_edit = true ;
2007-11-16 20:52:42 +00:00
} else if ( can_reply ( $thread , $forum , $logged_in_user )) {
2007-11-12 20:57:15 +00:00
$time_limit = $post -> timestamp + MAXIMUM_EDIT_TIME ;
2006-08-01 22:28:03 +00:00
$can_edit = time () < $time_limit ;
2006-12-29 20:57:29 +00:00
} else {
$can_edit = false ;
2006-08-01 22:28:03 +00:00
}
}
}
2006-08-01 21:45:05 +00:00
2004-02-02 23:34:39 +00:00
echo "
2007-07-14 18:33:48 +00:00
< tr class = \ " row " . $n . " \" valign= \" top \" >
2007-11-12 20:57:15 +00:00
< td rowspan = \ " 3 \" ><a name= \" " . $post -> id . " \" ></a><div class= \" authorcol \" >
2004-02-02 23:34:39 +00:00
" ;
2006-06-16 23:53:56 +00:00
// Print the user links
2007-11-12 20:57:15 +00:00
echo user_links ( $user , URL_BASE );
2005-02-08 21:20:00 +00:00
echo " <br> " ;
2006-06-16 23:53:56 +00:00
// Print the special user lines, if any
2005-01-18 13:00:38 +00:00
global $special_user_bitfield ;
2005-05-11 08:59:42 +00:00
$fstatus = " " ;
2006-06-16 23:53:56 +00:00
$keys = array_keys ( $special_user_bitfield );
for ( $i = 0 ; $i < sizeof ( $special_user_bitfield ); $i ++ ) {
2007-11-12 20:57:15 +00:00
if ( $user -> prefs -> privilege ( $keys [ $i ])) {
2006-06-16 23:53:56 +00:00
$fstatus .= $special_user_bitfield [ $keys [ $i ]] . " <br> " ;
2005-09-20 17:54:52 +00:00
}
2004-09-04 23:37:49 +00:00
}
2007-11-12 20:57:15 +00:00
if ( $user -> create_time > time () - ST_NEW_TIME ) $fstatus .= ST_NEW . " <br> " ;
2005-02-08 21:20:00 +00:00
if ( $fstatus ) echo " <font size= \" -2 \" > $fstatus </font> " ;
2004-12-21 23:06:31 +00:00
2006-06-16 23:53:56 +00:00
echo " <span class= \" authorinfo \" > " ;
2004-10-25 22:04:15 +00:00
if ( ! $filter || ! $rated_below_threshold ){
2007-11-12 20:57:15 +00:00
if ( $user -> prefs -> avatar != " " && ( ! $logged_in_user || ( $logged_in_user -> prefs -> hide_avatars == false ))) {
echo " <img width= \" " . AVATAR_WIDTH . " \" height= \" " . AVATAR_HEIGHT . " \" src= \" " . $user -> prefs -> avatar . " \" alt= \" Avatar \" ><br> " ;
2005-01-09 21:52:22 +00:00
}
2007-03-27 14:43:00 +00:00
}
2007-11-12 20:57:15 +00:00
$url = " pm.php?action=new&userid= " . $user -> id ;
$name = $user -> name ;
2007-11-01 17:54:44 +00:00
show_button ( $url , " Send message " , " Send $name a private message " );
2007-11-12 20:57:15 +00:00
echo " Joined: " , gmdate ( 'M j y' , $user -> create_time ), " <br> " ;
if ( ! isset ( $user -> nposts )) {
$user -> nposts = BoincPost :: count ( " user= $user->id " );
}
2007-05-15 10:06:38 +00:00
2007-03-27 14:43:00 +00:00
if ( function_exists ( 'project_forum_user_info' )){
project_forum_user_info ( $user );
} else { // default
// circumvent various forms of identity spoofing
// by displaying the user id of the poster.
2007-11-12 20:57:15 +00:00
//
echo " Posts: $user->nposts <br> " ;
echo " ID: " . $user -> id . " <br> " ;
echo " Credit: " . number_format ( $user -> total_credit ) . " <br> " ;
echo " RAC: " . number_format ( $user -> expavg_credit ) . " <br> " ;
2004-10-25 22:04:15 +00:00
}
2006-06-16 23:53:56 +00:00
echo " </span></div></td> " ;
2005-01-14 19:45:43 +00:00
2006-06-16 23:53:56 +00:00
if ( $controls == FORUM_CONTROLS ) {
echo " <td colspan= \" 2 \" class= \" postheader \" > " ;
2007-11-12 20:57:15 +00:00
echo " <form action= \" forum_rate.php?post= " , $post -> id , " \" method= \" post \" > " ;
2005-11-24 16:26:05 +00:00
} else {
2006-06-16 23:53:56 +00:00
echo " <td class= \" postheader \" > " ;
2005-11-24 16:26:05 +00:00
}
2004-09-04 23:37:49 +00:00
2007-11-12 20:57:15 +00:00
if ( $logged_in_user && $post -> timestamp > $last_visit ){
2007-11-01 20:41:24 +00:00
show_image ( NEW_IMAGE , " You haven't read this message yet " , NEW_IMAGE_HEIGHT );
2004-09-04 23:37:49 +00:00
}
2004-10-25 22:04:15 +00:00
if ( $rated_above_threshold ){
2007-11-01 20:41:24 +00:00
show_image ( EMPHASIZE_IMAGE , " This message has a high average rating " , EMPHASIZE_IMAGE_HEIGHT );
2004-10-25 22:04:15 +00:00
}
2005-01-09 21:52:22 +00:00
2007-11-12 20:57:15 +00:00
echo " <a href= \" forum_thread.php?id= " . $thread -> id . " &nowrap=true# $post->id\ " > Message " . $post->id . " </ a > - " ;
2007-11-15 22:51:05 +00:00
if ( $post -> hidden ) echo " <font color=red>[hidden] </font> " ;
2005-01-09 21:52:22 +00:00
echo "
2007-11-12 20:57:15 +00:00
Posted " , pretty_time_str( $post->timestamp );
2004-02-02 23:34:39 +00:00
;
2007-11-12 20:57:15 +00:00
if ( $post -> parent_post ) {
echo " - in response to <a href= \" forum_thread.php?id= " . $thread -> id . " &nowrap=true# " . $post -> parent_post . " \" >Message ID " . $post -> parent_post . " </a>. " ;
2007-11-02 18:48:48 +00:00
}
echo " " ;
if ( $can_edit && $controls != NO_CONTROLS ) {
2007-11-12 20:57:15 +00:00
show_button ( " forum_edit.php?id= " . $post -> id . " $tokens " , " Edit " , " Edit this message " );
2007-11-02 18:48:48 +00:00
}
2007-11-15 22:51:05 +00:00
if ( is_moderator ( $logged_in_user , $forum )) {
show_post_moderation_links ( $config , $logged_in_user , $post , $forum , $tokens );
2007-11-02 18:48:48 +00:00
}
2007-11-12 20:57:15 +00:00
if ( $post -> modified ) {
echo " <br>Last modified: " , pretty_time_Str ( $post -> modified );
2007-11-02 18:48:48 +00:00
}
2004-10-25 22:04:15 +00:00
if ( $rated_below_threshold && $filter ){
2007-11-02 18:48:48 +00:00
if ( $user_is_on_ignorelist ) {
$andtext = " and the user is on your ignore list " ;
}
2007-11-12 20:57:15 +00:00
echo " <br>This post has been filtered (rating: " . ( $post -> rating ()) . " ) $andtext , press <a href= \" ?id= " . $thread -> id . " &filter=false# " . $post -> id . " \" >here</a> to view this thread without filtering " ;
2004-02-02 23:34:39 +00:00
}
2006-06-16 23:53:56 +00:00
echo " </td></tr></form> " ;
2005-11-24 16:26:05 +00:00
echo " <tr class= \" row $n\ " >< td class = \ " postbody \" colspan= \" 2 \" > " ;
2006-06-16 23:53:56 +00:00
2005-01-09 21:52:22 +00:00
if ( ! $filter || ! $rated_below_threshold ){
2007-11-12 20:57:15 +00:00
$posttext = $post -> content ;
2005-09-20 17:54:52 +00:00
// If the creator of this post has a signature and
// wants it to be shown for this post AND the logged in
// user has signatures enabled: show it
//
2007-11-12 20:57:15 +00:00
if ( $post -> signature && ( ! $logged_in_user || ! $logged_in_user -> prefs -> hide_signatures )){
$posttext .= " \n ____________ \n " . $user -> prefs -> signature ;
2005-09-20 17:54:52 +00:00
}
2007-11-20 19:23:26 +00:00
$posttext = output_transform ( $posttext , $options );
2005-05-13 19:11:04 +00:00
2005-05-17 08:53:29 +00:00
echo " <p> " , $posttext , " </p> " ;
2006-06-16 23:53:56 +00:00
echo " </td></tr><tr><td class= \" postfooter \" >ID: <i> " , $post -> id ;
2006-07-10 17:18:42 +00:00
if ( $no_forum_rating != NULL ) {
2007-11-12 20:57:15 +00:00
echo " | <a href= \" forum_report_post.php?post= " . $post -> id . " \" > " ;
2007-11-01 20:41:24 +00:00
show_image ( REPORT_POST_IMAGE , " Report this post as offensive " , REPORT_POST_IMAGE_HEIGHT );
echo " </td> " ;
2006-07-10 17:18:42 +00:00
} else {
2007-11-12 20:57:15 +00:00
$rating = $post -> rating ();
2007-11-01 20:41:24 +00:00
echo " | Rating: " , $rating , " </i> | rate:
2007-11-12 20:57:15 +00:00
< a href = \ " forum_rate.php?post= " . $post -> id . " &choice=p $tokens\ " >
2007-11-01 20:41:24 +00:00
" ;
show_image ( RATE_POSITIVE_IMAGE , " Click if you like this message " , RATE_POSITIVE_IMAGE_HEIGHT );
2007-11-12 20:57:15 +00:00
echo " </a> / <a href= \" forum_rate.php?post= " . $post -> id . " &choice=n $tokens\ " > " ;
2007-11-01 20:41:24 +00:00
show_image ( RATE_NEGATIVE_IMAGE , " Click if you don't like this message " , RATE_NEGATIVE_IMAGE_HEIGHT );
2007-11-12 20:57:15 +00:00
echo " </a> <a href= \" forum_report_post.php?post= " . $post -> id . " \" > " ;
2007-11-01 20:41:24 +00:00
show_image ( REPORT_POST_IMAGE , " Report this post as offensive " , REPORT_POST_IMAGE_HEIGHT );
echo " </a></td> " ;
2006-07-10 17:18:42 +00:00
}
2007-11-17 00:44:21 +00:00
if (( $controls == FORUM_CONTROLS ) && ( can_reply ( $thread , $forum , $logged_in_user ))) {
2007-11-01 20:41:24 +00:00
echo " <td align=right class= \" postfooter \" > " ;
2007-11-12 20:57:15 +00:00
$url = " forum_reply.php?thread= " . $thread -> id . " &post= " . $post -> id . " #input " ;
2007-11-01 20:41:24 +00:00
show_button ( $url , " Reply " , " Post a reply to this message " );
echo " </td> " ;
2005-11-24 16:26:05 +00:00
} else {
2006-06-16 23:53:56 +00:00
echo " <td class= \" postfooter \" ></td> " ;
}
2005-11-24 16:26:05 +00:00
echo " </tr> " ;
2007-06-22 13:19:56 +00:00
} else {
echo " </td></tr><tr><td class= \" postfooter \" colspan= \" 2 \" > " ;
2004-02-02 23:34:39 +00:00
}
2005-11-24 16:26:05 +00:00
echo " <tr class= \" postseperator \" ><td colspan=3></td></tr> " ;
2004-02-02 23:34:39 +00:00
}
2007-11-20 19:23:26 +00:00
// Show a post and its context (e.g. for search results, user posts)
//
function show_post_and_context ( $post , $thread , $forum , $options , $n ) {
$thread = BoincThread :: lookup_id ( $post -> thread );
$forum = BoincForum :: lookup_id ( $thread -> forum );
$content = output_transform ( $post -> content , $options );
$when = time_diff_str ( $post -> timestamp , time ());
$user = lookup_user_id ( $post -> user );
$title = cleanup_title ( $thread -> title );
$m = $n % 2 ;
if ( $post -> hidden ) {
$deleted = " <br><font color=red>[Hidden by a moderator]</font> " ;
} else {
$deleted = " " ;
}
echo "
< tr class = row $m >
< td >
$n )
" ;
switch ( $forum -> parent_type ) {
case 0 :
$category = BoincCategory :: lookup_id ( $forum -> category );
show_forum_title ( $category , $forum , $thread );
break ;
case 1 :
show_team_forum_title ( $forum );
break ;
}
echo "
( < a href = \ " forum_thread.php?id= " . $thread -> id . " &nowrap=true# " . $post -> id . " \" >Message " . $post -> id . " </a>)
< br >
Posted $when by " .user_links( $user ). " $deleted
< hr >
$content
</ td ></ tr >
" ;
}
2007-11-12 20:57:15 +00:00
function check_banished ( $user ) {
$x = $user -> prefs -> banished_until ;
if ( $x > time ()) {
error_page (
" You may not post or rate messages until " . gmdate ( 'M j, Y' , $x )
);
2005-09-20 17:54:52 +00:00
}
2004-02-02 23:34:39 +00:00
}
2006-06-16 23:53:56 +00:00
function post_rules () {
return "
2006-06-12 18:53:09 +00:00
< ul >
2006-09-25 18:51:50 +00:00
< li > Posts must be 'kid friendly' : they may not contain
content that is obscene , hate - related ,
sexually explicit or suggestive .
2006-06-12 18:53:09 +00:00
< li > No commercial advertisements .
2006-09-25 18:51:50 +00:00
< li > No links to web sites involving sexual content ,
gambling , or intolerance of others .
< li > No messages intended to annoy or antagonize other people ,
or to hijack a thread .
2006-06-12 18:53:09 +00:00
< li > No messages that are deliberately hostile or insulting .
< li > No abusive comments involving race , religion ,
2006-09-25 18:51:50 +00:00
nationality , gender , class or sexuality .
2006-06-12 18:53:09 +00:00
</ ul >
2006-06-16 23:53:56 +00:00
" ;
}
function post_warning () {
return " <br><br>
< table >< tr >< td >
< font size =- 2 >
Rules :
" .post_rules(). "
2006-06-12 18:53:09 +00:00
< a href = moderation . php > More info </ a >
</ font >
</ td ></ tr ></ table >
2005-02-16 00:24:53 +00:00
" ;
}
2007-11-12 20:57:15 +00:00
// Various functions for adding/hiding/unhiding stuff.
// These take care of counts and timestamps.
// Don't do these things directly - use these functions
//
function create_post ( $content , $parent_id , $user , $forum , $thread , $signature ) {
$content = substr ( $content , 0 , 64000 );
$content = mysql_real_escape_string ( $content );
$now = time ();
$sig = $signature ? 1 : 0 ;
$id = BoincPost :: insert ( " (thread, user, timestamp, content, parent_post, signature) values ( $thread->id , $user->id , $now , ' $content ', $parent_id , $sig ) " );
if ( ! $id ) return null ;
// send emails to subscribed users
//
$subs = BoincSubscription :: enum ( " threadid= $thread->id " );
foreach ( $subs as $sub ) {
if ( $user -> id == $sub -> userid ) continue ;
$user2 = BoincUser :: lookup_id ( $sub -> userid );
$visit_time = thread_last_visit ( $user2 , $thread );
if ( $visit_time > $sub -> notified_time ) {
send_reply_notification_email ( $thread , $user2 );
}
2006-08-08 20:32:37 +00:00
}
2007-11-12 20:57:15 +00:00
$user -> update ( " posts=posts+1 " );
$thread -> update ( " replies=replies+1, timestamp= $now " );
$forum -> update ( " posts=posts+1, timestamp= $now " );
2006-08-08 20:32:37 +00:00
}
2007-11-12 20:57:15 +00:00
function create_thread ( $title , $content , $user , $forum , $signature ) {
$title = trim ( $title );
$title = strip_tags ( $title );
$title = mysql_real_escape_string ( $title );
$now = time ();
$id = BoincThread :: insert ( " (forum, owner, title, create_time, timestamp, replies) values ( $forum->id , $user->id , ' $title ', $now , $now , -1) " );
if ( ! $id ) return null ;
$thread = BoincThread :: lookup_id ( $id );
create_post ( $content , 0 , $user , $forum , $thread , $signature );
$forum -> update ( " threads=threads+1 " );
return $thread ;
}
function hide_post ( $post , $thread , $forum ) {
$post -> update ( " hidden=1 " );
$thread -> update ( " replies=replies-1 " );
return $forum -> update ( " posts=posts-1 " );
}
function unhide_post ( $post , $thread , $forum ) {
$now = time ();
$post -> update ( " hidden=0 " );
$thread -> update ( " replies=replies+1, timestamp= $now " );
return $forum -> update ( " posts=posts+1, timestamp= $now " );
}
function move_post ( $post , $old_thread , $old_forum , $new_thread , $new_forum ) {
$now = time ();
$post -> update ( " thread= $new_thread->id " );
$old_thread -> update ( " replies=replies-1 " );
$new_thread -> update ( " replies=replies+1, timestamp= $now " );
$old_forum -> update ( " posts=posts-1 " );
return $new_forum -> update ( " posts=posts+1, timestamp= $now " );
}
function hide_thread ( $thread , $forum ) {
$thread -> update ( " hidden=1 " );
$forum -> update ( " threads=threads-1 " );
return $forum -> update ( " posts=posts- $thread->replies -1 " );
}
function unhide_thread ( $thread , $forum ) {
$now = time ();
$thread -> update ( " hidden=0 " );
return $forum -> update ( " threads=threads+1, posts=posts+ $thread->replies +1, timestamp= $now " );
}
function move_thread ( $thread , $old_forum , $new_forum ) {
$now = time ();
$old_forum -> update ( " threads=threads-1, posts=posts- $thread->replies -1 " );
$new_forum -> update ( " threads=threads+1, posts=posts+ $thread->replies +1, timestamp= $now " );
return $thread -> update ( " forum= $new_forum->id " );
}
// $show_hidden: 1 if it is a moderator reading
// Error page if this function returns NULL.
// $forumID - int
// $min - int
// $nRec - int
// $sort_style - string (checked by switch statement)
// $show_hidden - bool (not directly passed to SQL)
// $sticky - bool (not directly passed to SQL)
//
function get_forum_threads (
$forumID , $start =- 1 , $nRec =- 1 , $sort_style = MODIFIED_NEW ,
$show_hidden = 0 , $sticky = 1
) {
//if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) {
// return NULL; // Something is wrong here.
//}
$sql = 'forum = ' . $forumID ;
if ( $sticky ){
$stickysql = " sticky DESC, " ;
}
if ( ! $show_hidden ) {
$sql .= ' AND hidden = 0' ;
}
switch ( $sort_style ) {
case MODIFIED_NEW :
$sql .= ' ORDER BY ' . $stickysql . 'timestamp DESC' ;
break ;
case MODIFIED_OLD :
$sql .= ' ORDER BY ' . $stickysql . 'timestamp ASC' ;
break ;
case VIEWS_MOST :
$sql .= ' ORDER BY ' . $stickysql . 'views DESC' ;
break ;
case REPLIES_MOST :
$sql .= ' ORDER BY ' . $stickysql . 'replies DESC' ;
break ;
case CREATE_TIME_NEW :
$sql .= ' ORDER by ' . $stickysql . 'create_time desc' ;
break ;
case CREATE_TIME_OLD :
$sql .= ' ORDER by ' . $stickysql . 'create_time asc' ;
break ;
case 'sufferers' :
$sql .= ' ORDER by ' . $stickysql . 'sufferers desc' ;
break ;
case 'activity' :
$sql .= ' ORDER by ' . $stickysql . 'activity desc' ;
break ;
case 'score' :
$sql .= ' ORDER by ' . $stickysql . 'score desc' ;
break ;
default :
$sql .= ' ORDER BY ' . $stickysql . 'timestamp DESC' ;
break ;
}
if ( $start > - 1 ) {
$sql .= ' LIMIT ' . $start ;
if ( $nRec > - 1 ) {
$sql .= ', ' . $nRec ;
}
} else if ( $nRec > - 1 ) {
$sql .= ' LIMIT ' . $nRec ;
}
return BoincThread :: enum ( $sql );
}
// $show_hidden = true when it is a moderator reading
// error_page if this function returns NULL.
// $sort_style - string (checked by switch statement)
// $show_hidden - bool (not directly passed to SQL)
//
2007-11-15 22:51:05 +00:00
function get_thread_posts ( $threadid , $sort_style , $show_hidden ) {
2007-11-12 20:57:15 +00:00
$sql = " thread= $threadid " ;
if ( ! $show_hidden ) {
$sql .= ' AND hidden = 0' ;
}
switch ( $sort_style ) {
case CREATE_TIME_NEW :
$sql .= ' ORDER BY timestamp desc' ;
break ;
case CREATE_TIME_OLD :
$sql .= ' ORDER BY timestamp asc' ;
break ;
case POST_SCORE :
$sql .= ' ORDER BY score DESC' ;
break ;
default :
$sql .= ' ORDER BY timestamp asc' ;
break ;
}
return BoincPost :: enum ( $sql );
}
2007-11-15 22:51:05 +00:00
// Show the links for possible moderation actions related to a single post
2007-11-12 20:57:15 +00:00
//
2007-11-15 22:51:05 +00:00
function show_post_moderation_links (
$config , $logged_in_user , $post , $forum , $tokens
2007-11-12 20:57:15 +00:00
){
2007-11-15 22:51:05 +00:00
$moderators_allowed_to_ban = parse_bool ( $config , " moderators_allowed_to_ban " );
$moderators_vote_to_ban = parse_bool ( $config , " moderators_vote_to_ban " );
if ( $post -> hidden ) {
show_button ( " forum_moderate_post_action.php?action=unhide&id= " . $post -> id . " $tokens " , " Unhide " , " Unhide this post " );
} else {
show_button ( " forum_moderate_post.php?action=hide&id= " . $post -> id . " $tokens " , " Hide " , " Hide this post " );
2007-11-12 20:57:15 +00:00
}
2007-11-15 22:51:05 +00:00
show_button (
" forum_moderate_post.php?action=move&id= " . $post -> id . " $tokens " ,
" Move " , " Move post to a different thread "
);
if ( $forum -> parent_type == 0 ) {
if ( $logged_in_user -> prefs -> privilege ( S_ADMIN ) || ( $logged_in_user -> prefs -> privilege ( S_MODERATOR ) && $moderators_allowed_to_ban )) {
show_button ( " forum_moderate_post.php?action=banish_user&id= " . $post -> id . " &userid= " . $post -> user . " $tokens " , " Banish author " , " Banish author " );
}
if ( $logged_in_user -> prefs -> privilege ( S_MODERATOR ) && $moderators_vote_to_ban ) {
require_once ( " ../inc/forum_banishment_vote.inc " );
if ( vote_is_in_progress ( $post -> user )) {
show_button ( " forum_banishment_vote.php?action=yes&userid= " . $post -> user , " Vote to banish author " , " Vote to banish author " );
show_button ( " forum_banishment_vote.php?action=no&userid= " . $post -> user , " Vote not to banish author " , " Vote not to banish author " );
} else {
show_button ( " forum_banishment_vote.php?action=start&userid= " . $post -> user , " Start vote to banish author " , " Start vote to banish author " );
}
}
2007-11-12 20:57:15 +00:00
}
2007-11-15 22:51:05 +00:00
}
function check_create_thread_access ( $user , $forum ) {
if ( $forum -> is_dev_blog ){
if (
( ! $user -> prefs -> privilege ( S_SCIENTIST )) &&
( ! $user -> prefs -> privilege ( S_DEV )) &&
( ! $user -> prefs -> privilege ( S_ADMIN ))
) {
error_page ( " This forum is marked as a development blog, only people directly working with the project may start a new thread here. <br/>However, you may post a reply to an existing thread. " );
}
2007-11-12 20:57:15 +00:00
}
2007-11-15 22:51:05 +00:00
check_post_access ( $user , $forum );
}
function check_post_access ( $user , $forum ) {
switch ( $forum -> parent_type ) {
case 0 :
if ( $user -> prefs -> privilege ( S_MODERATOR )) return ;
2007-11-12 20:57:15 +00:00
break ;
2007-11-15 22:51:05 +00:00
case 1 :
$team = BoincTeam :: lookup_id ( $forum -> category );
if ( is_team_admin ( $user , $team )) return ;
// non-team-members can't post
//
if ( $user -> teamid != $team -> id ) {
error_page ( " Only team members can post to the team message board " );
}
2007-11-12 20:57:15 +00:00
break ;
}
2007-11-15 22:51:05 +00:00
// If user haven't got enough credit (according to forum regulations)
// We do not tell the (ab)user how much this is -
// no need to make it easy for them to break the system.
//
if ( $user -> total_credit < $forum -> post_min_total_credit || $user -> expavg_credit < $forum -> post_min_expavg_credit ) {
error_page ( tra ( " In order to create a new thread in %1 you must have a certain amount of credit. This is to prevent and protect against abuse of the system. " , $forum -> title ));
2007-11-12 20:57:15 +00:00
}
2007-11-15 22:51:05 +00:00
// If the user is posting faster than forum regulations allow
// Tell the user to wait a while before creating any more posts
//
if ( time () - $user -> last_post < $forum -> min_post_interval ) {
error_page ( tra ( " You cannot create any more threads right now. Please wait a while before trying again. This delay has been enforced to protect against abuse of the system. " ));
2007-11-12 20:57:15 +00:00
}
}
2007-11-15 22:51:05 +00:00
function check_reply_access ( $user , $forum , $thread ) {
if ( $thread -> locked && ! is_moderator ( $user , $forum )) {
error_page (
" This thread is locked. Only forum moderators and administrators are allowed to post there. "
);
2007-11-12 20:57:15 +00:00
}
2007-11-15 22:51:05 +00:00
if ( $thread -> hidden ) {
error_page (
" Can't post to a hidden thread. "
);
2007-11-12 20:57:15 +00:00
}
2007-11-15 22:51:05 +00:00
check_post_access ( $user , $forum );
}
function is_moderator ( $user , $forum ) {
if ( ! $user ) return false ;
switch ( $forum -> parent_type ) {
case 0 :
if ( $user -> prefs -> privilege ( S_MODERATOR )) return true ;
if ( $user -> prefs -> privilege ( S_ADMIN )) return true ;
if ( $user -> prefs -> privilege ( S_DEV )) return true ;
break ;
case 1 :
2007-11-18 04:10:37 +00:00
if ( $user -> prefs -> privilege ( S_ADMIN )) return true ;
2007-11-15 22:51:05 +00:00
$team = BoincTeam :: lookup_id ( $forum -> category );
return is_team_admin ( $user , $team );
break ;
2006-12-29 20:57:29 +00:00
}
2007-11-15 22:51:05 +00:00
return false ;
2006-12-29 20:57:29 +00:00
}
2004-02-02 23:34:39 +00:00
?>