2003-07-18 21:38:51 +00:00
< ? php
2007-09-29 12:53:16 +00:00
2007-11-12 20:57:15 +00:00
// This file allows you to create a new thread in a forum
// At first it displays an input box and when you submit
// it will apply the changes by calling methods on the forum
2006-07-01 20:03:48 +00:00
require_once ( '../inc/forum_email.inc' );
2004-02-02 23:34:39 +00:00
require_once ( '../inc/forum.inc' );
2007-04-19 18:22:38 +00:00
require_once ( '../inc/akismet.inc' );
2003-07-18 21:38:51 +00:00
2007-11-12 20:57:15 +00:00
$logged_in_user = get_logged_in_user ();
BoincForumPrefs :: lookup ( $logged_in_user );
2004-09-04 23:37:49 +00:00
2006-08-08 20:32:37 +00:00
check_banished ( $logged_in_user );
2005-02-13 21:33:02 +00:00
$forumid = get_int ( " id " );
2007-11-12 20:57:15 +00:00
$forum = BoincForum :: lookup_id ( $forumid );
2006-06-16 23:53:56 +00:00
2007-11-12 20:57:15 +00:00
if ( $forum -> is_dev_blog ){
2007-01-22 22:39:22 +00:00
if (
2007-11-12 20:57:15 +00:00
( ! $logged_in_user -> prefs -> privilege ( S_SCIENTIST )) &&
( ! $logged_in_user -> prefs -> privilege ( S_DEV )) &&
( ! $logged_in_user -> prefs -> privilege ( S_ADMIN ))
2007-01-22 22:39:22 +00:00
) {
// Since this is a devBlog only people at the project can start threads here.
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
if ( ! $logged_in_user -> prefs -> privilege ( S_MODERATOR ) && ( $logged_in_user -> total_credit < $forum -> post_min_total_credit || $logged_in_user -> expavg_credit < $forum -> post_min_expavg_credit )) {
2005-04-20 21:11:20 +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.
2007-11-12 20:57:15 +00:00
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 ));
2005-04-20 21:11:20 +00:00
}
2007-11-12 20:57:15 +00:00
if ( time () - $logged_in_user -> last_post < $forum -> min_post_interval ){
2005-04-20 21:11:20 +00:00
//If the user is posting faster than forum regulations allow
//Tell the user to wait a while before creating any more posts
2007-11-02 14:43:02 +00:00
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. " ));
2005-04-20 21:11:20 +00:00
}
2005-02-13 21:33:02 +00:00
$title = post_str ( " title " , true );
$content = post_str ( " content " , true );
2007-09-29 18:40:46 +00:00
$preview = post_str ( " preview " , true );
2006-06-16 23:53:56 +00:00
2007-09-29 12:53:16 +00:00
if ( $content && $title && ( ! $preview )){
2006-06-16 23:53:56 +00:00
if ( post_str ( 'add_signature' , true ) == " add_it " ){
$add_signature = true ; // set a flag and concatenate later
} else {
2005-02-13 21:33:02 +00:00
$add_signature = false ;
2003-11-28 22:35:01 +00:00
}
2007-11-12 20:57:15 +00:00
check_tokens ( $logged_in_user -> authenticator );
2007-04-19 18:22:38 +00:00
akismet_check ( $logged_in_user , $content );
2007-11-12 20:57:15 +00:00
$thread = create_thread (
$title , $content , $logged_in_user , $forum , $add_signature
);
header ( 'Location: forum_thread.php?id=' . $thread -> id );
2003-07-24 22:57:41 +00:00
}
2003-08-01 20:30:25 +00:00
2007-10-31 23:50:21 +00:00
page_head ( 'Create new thread' );
2003-08-01 20:30:25 +00:00
2007-11-12 20:57:15 +00:00
$category = BoincCategory :: lookup_id ( $forum -> category );
show_forum_title ( $logged_in_user , $category , $forum , null , true );
2003-08-01 20:30:25 +00:00
2007-09-29 12:53:16 +00:00
if ( $preview == tra ( " Preview " )) {
2007-11-12 20:57:15 +00:00
$options = null ;
2007-09-29 12:53:16 +00:00
echo " <div id= \" preview \" > \n " ;
echo " <div class= \" header \" > " . tra ( " Preview " ) . " </div> \n " ;
echo output_transform ( $content , $options );
echo " </div> \n " ;
}
2007-11-12 20:57:15 +00:00
echo " <form action= \" forum_post.php?id= " . $forum -> id . " \" method= \" POST \" > \n " ;
echo form_tokens ( $logged_in_user -> authenticator );
2003-08-13 22:08:12 +00:00
2004-06-07 03:34:07 +00:00
start_table ();
2003-08-13 22:08:12 +00:00
2007-11-02 14:43:02 +00:00
row1 ( tra ( " Create a new thread " )); //New thread
2006-06-16 23:53:56 +00:00
$submit_help = " " ;
$body_help = " " ;
2003-08-13 22:08:12 +00:00
2005-09-27 20:38:44 +00:00
//Title
2006-08-22 09:04:28 +00:00
if ( $content && ! $title ) $submit_help = " <br /><font color= \" red \" >Remember to add a title</font> " ;
2007-11-02 14:43:02 +00:00
row2 ( tra ( " Title " ) . $submit_help , " <input type= \" text \" name= \" title \" size= \" 62 \" value= \" " . stripslashes ( htmlspecialchars ( $title )) . " \" > " );
2005-09-27 20:38:44 +00:00
//Message
2007-11-02 14:43:02 +00:00
row2 ( tra ( " Message " ) . html_info () . post_warning () . $body_help , " <textarea name= \" content \" rows= \" 12 \" cols= \" 54 \" > " . stripslashes ( htmlspecialchars ( $content )) . " </textarea> " );
2003-08-13 22:08:12 +00:00
2007-11-12 20:57:15 +00:00
if ( ! $logged_in_user -> prefs -> no_signature_by_default ) {
2005-02-13 21:33:02 +00:00
$enable_signature = " checked= \" true \" " ;
} else {
$enable_signature = " " ;
}
2005-09-27 20:38:44 +00:00
2007-11-02 14:43:02 +00:00
row2 ( " " , " <input name= \" add_signature \" value= \" add_it \" " . $enable_signature . " type= \" checkbox \" > " . tra ( " Add my signature to this post " ));
2007-09-29 12:53:16 +00:00
row2 ( " " , " <input type= \" submit \" name= \" preview \" value= \" " . tra ( " Preview " ) . " \" > <input type= \" submit \" value= \" OK \" > " );
2003-08-13 22:08:12 +00:00
2006-06-16 23:53:56 +00:00
2007-11-12 20:57:15 +00:00
end_table ();
2003-08-13 22:08:12 +00:00
echo " </form> \n " ;
2003-07-18 21:38:51 +00:00
2003-08-15 00:58:48 +00:00
page_tail ();
2007-11-12 20:57:15 +00:00
$cvs_version_tracker [] = " \$ Id $ " ;
2003-11-28 22:35:01 +00:00
?>