2003-07-19 00:26:18 +00:00
< ? php
2007-07-08 12:31:13 +00:00
2007-11-12 20:57:15 +00:00
// Using this page you can edit a post.
// First it displays a box to edit in, and when you submit the changes
// it will call the methods on the post to make the changes.
//
2003-08-13 22:08:12 +00:00
2004-02-02 23:34:39 +00:00
require_once ( '../inc/forum.inc' );
2004-12-27 03:42:11 +00:00
2007-11-12 20:57:15 +00:00
$logged_in_user = get_logged_in_user ();
BoincForumPrefs :: lookup ( $logged_in_user );
2005-01-18 13:00:38 +00:00
2006-06-16 23:53:56 +00:00
// if user is a project admin or project developer or forum moderator,
2005-05-12 14:57:16 +00:00
// allow them to edit their own posts indefinitely.
2007-11-12 20:57:15 +00:00
//
$is_spec = $logged_in_user -> prefs -> privilege ( S_MODERATOR ) ||
$logged_in_user -> prefs -> privilege ( S_ADMIN ) ||
$logged_in_user -> prefs -> privilege ( S_DEV );
2005-05-12 14:57:16 +00:00
2005-02-13 21:33:02 +00:00
$postid = get_int ( " id " );
2007-11-12 20:57:15 +00:00
$post = BoincPost :: lookup_id ( $postid );
2007-11-14 22:49:31 +00:00
if ( ! $post ) error_page ( " no such post " );
2007-11-12 20:57:15 +00:00
$thread = BoincThread :: lookup_id ( $post -> thread );
2007-11-14 22:49:31 +00:00
if ( ! $thread ) error_page ( " no such thread " );
2006-06-16 23:53:56 +00:00
2007-11-12 20:57:15 +00:00
// Check some prerequisites for editing the post
//
if ( ! $is_spec && ( time () > $post -> timestamp + MAXIMUM_EDIT_TIME )){
2006-06-16 23:53:56 +00:00
error_page ( " You can no longer edit this post.<br />Posts can only be edited at most " . ( MAXIMUM_EDIT_TIME / 60 ) . " minutes after they have been created. " );
}
2007-11-12 20:57:15 +00:00
$post_owner = BoincUser :: lookup_id ( $post -> user );
if (( $logged_in_user -> id != $post_owner -> id ) || ( can_reply ( $thread , $logged_in_user ) == false )) {
2006-06-16 23:53:56 +00:00
error_page ( " You are not authorized to edit this post. " );
2005-02-13 21:33:02 +00:00
}
2005-01-18 13:00:38 +00:00
2007-11-12 20:57:15 +00:00
$thread_owner = BoincUser :: lookup_id ( $thread -> owner );
$can_edit_title = ( $post -> parent_post == 0 and $thread_owner -> id == $logged_in_user -> id );
2004-04-13 23:55:05 +00:00
2007-09-29 12:53:16 +00:00
$content = post_str ( " content " , true );
2007-11-14 22:49:31 +00:00
$title = post_str ( " title " , true );
2007-09-29 12:53:16 +00:00
$preview = post_str ( " preview " , true );
2007-11-12 20:57:15 +00:00
if ( post_str ( 'submit' , true ) && ( ! $preview )) {
check_tokens ( $logged_in_user -> authenticator );
2007-07-08 12:31:13 +00:00
2007-11-12 20:57:15 +00:00
if ( post_str ( 'add_signature' , true ) == " 1 " ) {
$add_signature = 1 ;
2007-07-08 12:31:13 +00:00
} else {
2007-11-12 20:57:15 +00:00
$add_signature = 0 ;
2007-07-08 12:31:13 +00:00
}
2007-11-12 20:57:15 +00:00
$content = substr ( $content , 0 , 64000 );
2007-11-12 22:28:17 +00:00
$content = BoincDb :: escape_string ( $content );
2007-11-12 20:57:15 +00:00
$post -> update ( " signature= $add_signature , content=' $content ' " );
2007-07-08 12:31:13 +00:00
2006-06-16 23:53:56 +00:00
// If this post belongs to the creator of the thread and is at top-level
2007-11-12 20:57:15 +00:00
// (ie. not a response to another post)
// allow the user to modify the thread title
//
2006-06-16 23:53:56 +00:00
if ( $can_edit_title ){
2007-11-14 22:49:31 +00:00
$title = trim ( $title );
$title = strip_tags ( $title );
$title = BoincDb :: escape_string ( $title );
$thread -> update ( " title=' $title ' " );
2004-04-13 23:55:05 +00:00
}
2003-08-14 00:56:20 +00:00
2007-11-12 20:57:15 +00:00
header ( " Location: forum_thread.php?id= $thread->id " );
2003-07-19 00:26:18 +00:00
}
2004-05-11 22:49:23 +00:00
page_head ( 'Forum' );
2003-07-19 00:26:18 +00:00
2007-11-12 20:57:15 +00:00
$forum = BoincForum :: lookup_id ( $thread -> forum );
$category = BoincCategory :: lookup_id ( $forum -> category );
2003-07-19 00:26:18 +00:00
2007-11-15 00:27:02 +00:00
show_forum_header ( $logged_in_user );
show_forum_title ( $category , $forum , $thread );
2003-07-19 00:26:18 +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_edit.php?id= " . $post -> id . " \" method= \" POST \" > \n " ;
echo form_tokens ( $logged_in_user -> authenticator );
2004-06-07 03:34:07 +00:00
start_table ();
row1 ( " Edit your post " );
2006-06-16 23:53:56 +00:00
if ( $can_edit_title ) {
//If this is the user can edit the thread title display a way of doing so
2007-09-29 12:53:16 +00:00
if ( $preview ) {
row2 (
2007-11-02 14:43:02 +00:00
tra ( " Title " ) . html_info (),
2007-09-29 12:53:16 +00:00
" <input type= \" text \" name= \" title \" value= \" " . stripslashes ( htmlspecialchars ( $title )) . " \" > "
);
} else {
row2 (
2007-11-02 14:43:02 +00:00
tra ( " Title " ) . html_info (),
2007-11-12 20:57:15 +00:00
'<input type="text" name="title" value="' . stripslashes ( htmlspecialchars ( $thread -> title )) . '">'
2007-09-29 12:53:16 +00:00
);
}
2004-04-13 23:55:05 +00:00
};
2003-08-13 22:08:12 +00:00
2007-09-29 12:53:16 +00:00
if ( $preview ) {
row2 (
2007-11-02 14:43:02 +00:00
tra ( " Message " ) . html_info () . post_warning (),
2007-09-29 12:53:16 +00:00
" <textarea name= \" content \" rows= \" 12 \" cols= \" 80 \" > " . stripslashes ( htmlspecialchars ( $content )) . " </textarea> "
);
} else {
row2 (
2007-11-02 14:43:02 +00:00
tra ( " Message " ) . html_info () . post_warning (),
2007-11-12 20:57:15 +00:00
'<textarea name="content" rows="12" cols="80">' . stripslashes ( htmlspecialchars ( $post -> content )) . '</textarea>'
2007-09-29 12:53:16 +00:00
);
}
2007-07-08 12:31:13 +00:00
2007-11-12 20:57:15 +00:00
if ( $post -> signature ) {
2007-07-08 12:31:13 +00:00
$enable_signature = " checked= \" true \" " ;
} else {
$enable_signature = " " ;
}
row2 ( " " , " <input id= \" add_signature \" name= \" add_signature \" value= \" 1 \" " . $enable_signature . " type= \" checkbox \" >
2007-11-02 14:43:02 +00:00
< label for = \ " add_signature \" > " . tra ( " Add my signature to this post " ) . " </label> " );
2007-09-29 12:53:16 +00:00
row2 ( " " , " <input type= \" submit \" name= \" preview \" value= \" " . tra ( " Preview " ) . " \" ><input type= \" submit \" name= \" submit \" value= \" OK \" > "
2004-06-07 03:34:07 +00:00
);
end_table ();
2003-08-13 22:08:12 +00:00
echo " </form> " ;
2003-08-15 01:01:00 +00:00
page_tail ();
2003-07-19 00:26:18 +00:00
2007-11-12 20:57:15 +00:00
$cvs_version_tracker [] = " \$ Id $ " ; //Generated automatically - do not edit
2003-12-04 22:42:51 +00:00
?>