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-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' );
2009-06-23 17:15:17 +00:00
require_once ( '../inc/bbcode_html.inc' );
2007-04-19 18:22:38 +00:00
require_once ( '../inc/akismet.inc' );
2011-06-14 05:42:52 +00:00
require_once ( '../inc/news.inc' );
2003-07-18 21:38:51 +00:00
2011-06-14 05:42:52 +00:00
check_get_args ( array ( " id " , " title " , " force_title " , " tnow " , " ttok " , " export " ));
2011-02-09 22:11:34 +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
2009-12-16 22:35:08 +00:00
if ( ! user_can_create_thread ( $logged_in_user , $forum )) {
error_page (
2009-12-17 00:17:37 +00:00
" Only project admins may create a thread here.
However , you may reply existing threads . "
2009-12-16 22:35:08 +00:00
);
}
2009-12-17 00:17:37 +00:00
check_post_access ( $logged_in_user , $forum );
2007-01-22 22:39:22 +00:00
2005-02-13 21:33:02 +00:00
$title = post_str ( " title " , true );
2008-12-29 10:19:25 +00:00
if ( ! $title ) $title = get_str ( " title " , true );
$force_title = get_str ( " force_title " , true );
2011-06-14 05:42:52 +00:00
$export = post_str ( " export " , true );
2005-02-13 21:33:02 +00:00
$content = post_str ( " content " , true );
2007-09-29 18:40:46 +00:00
$preview = post_str ( " preview " , true );
2008-10-09 18:28:55 +00:00
$warning = null ;
2006-06-16 23:53:56 +00:00
2007-09-29 12:53:16 +00:00
if ( $content && $title && ( ! $preview )){
2011-06-14 05:42:52 +00:00
if ( post_str ( 'add_signature' , true ) == " add_it " ){
$add_signature = true ; // set a flag and concatenate later
2006-06-16 23:53:56 +00:00
} else {
2011-06-14 05:42:52 +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 );
2008-10-09 18:28:55 +00:00
if ( ! akismet_check ( $logged_in_user , $content )) {
$warning = " Your message was flagged as spam by the Akismet
anti - spam system . Please modify your text and try again .
" ;
2008-10-11 18:13:33 +00:00
$preview = tra ( " Preview " );
2008-10-09 18:28:55 +00:00
} else {
$thread = create_thread (
2011-06-14 05:42:52 +00:00
$title , $content , $logged_in_user , $forum , $add_signature , $export
2008-10-09 18:28:55 +00:00
);
header ( 'Location: forum_thread.php?id=' . $thread -> id );
}
2003-07-24 22:57:41 +00:00
}
2003-08-01 20:30:25 +00:00
2009-06-23 17:13:35 +00:00
page_head ( 'Create new thread' , '' , '' , '' , $bbcode_js );
2007-11-15 00:27:02 +00:00
show_forum_header ( $logged_in_user );
2007-11-15 22:51:05 +00:00
2008-10-09 18:28:55 +00:00
if ( $warning ) {
echo " <span class=error> $warning </span><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 , null );
2007-11-16 21:48:28 +00:00
break ;
case 1 :
show_team_forum_title ( $forum );
break ;
2007-11-15 22:51:05 +00:00
}
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 ;
2011-02-11 18:09:08 +00:00
echo " <h2> " . tra ( " Preview " ) . " </h2> \n " ;
echo " <div class= \" pm_preview \" > " ;
2007-09-29 12:53:16 +00:00
echo output_transform ( $content , $options );
echo " </div> \n " ;
}
2009-06-23 16:37:13 +00:00
echo " <form action= \" forum_post.php?id= " . $forum -> id . " \" method= \" POST \" name= \" post \" onsubmit= \" return checkForm(this) \" > \n " ;
2007-11-12 20:57:15 +00:00
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
2011-06-14 05:42:52 +00:00
row1 ( tra ( " Create a new thread " ));
2006-06-16 23:53:56 +00:00
$submit_help = " " ;
$body_help = " " ;
2003-08-13 22:08:12 +00:00
2008-06-05 20:32:21 +00:00
if ( $content && ! $title ) {
$submit_help = " <br /><font color= \" red \" >Remember to add a title</font> " ;
}
2008-12-29 10:19:25 +00:00
if ( $force_title && $title ){
row2 ( tra ( " Title " ), htmlspecialchars ( $title ) . " <input type= \" hidden \" name= \" title \" value= \" " . htmlspecialchars ( $title ) . " \" > " );
} else {
row2 ( tra ( " Title " ) . $submit_help ,
2008-06-05 20:32:21 +00:00
" <input type= \" text \" name= \" title \" size= \" 62 \" value= \" " . htmlspecialchars ( $title ) . " \" > "
2008-12-29 10:19:25 +00:00
);
}
2008-06-05 20:32:21 +00:00
row2 ( tra ( " Message " ) . html_info () . post_warning () . $body_help ,
2010-12-21 17:15:57 +00:00
$bbcode_html . " <textarea name= \" content \" rows= \" 12 \" cols= \" 80 \" class= \" message_field \" > " . htmlspecialchars ( $content ) . " </textarea> "
2008-06-05 20:32:21 +00:00
);
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
2011-06-14 05:42:52 +00:00
if ( is_news_forum ( $forum )) {
row2 ( " " , " <input name=export type=checkbox> Show this item as a Notice in the BOINC Manager<br><span class=note>Do so only for items likely to be of interest to all volunteers</span> " );
}
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
?>