2003-07-19 00:26:18 +00:00
< ? php
2007-07-08 12:31:13 +00:00
$cvs_version_tracker [] = " \$ Id $ " ; //Generated automatically - do not edit
2006-06-16 23:53:56 +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' );
2006-06-16 23:53:56 +00:00
require_once ( '../inc/forum_std.inc' );
2003-07-19 00:26:18 +00:00
2004-12-27 03:42:11 +00:00
db_init ();
2006-06-16 23:53:56 +00:00
$logged_in_user = re_get_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.
2006-06-16 23:53:56 +00:00
$is_spec = $logged_in_user -> isSpecialUser ( S_MODERATOR ) ||
$logged_in_user -> isSpecialUser ( S_ADMIN ) ||
$logged_in_user -> isSpecialUser ( S_DEV );
2005-05-12 14:57:16 +00:00
2005-02-13 21:33:02 +00:00
$postid = get_int ( " id " );
2006-06-16 23:53:56 +00:00
$post = new Post ( $postid );
$thread = $post -> getThread ();
// Check some prerequisits for editting the post
if ( ! $is_spec && ( time () > $post -> getTimestamp () + MAXIMUM_EDIT_TIME )){
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. " );
}
$post_owner = $post -> getOwner ();
2006-12-29 20:57:29 +00:00
if (( $logged_in_user -> getID () != $post_owner -> getID ()) || ( 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
2006-06-16 23:53:56 +00:00
$thread_owner = $thread -> getOwner ();
$can_edit_title = ( $post -> getParentPostID () == 0 and $thread_owner -> getID () == $logged_in_user -> getID ());
2004-04-13 23:55:05 +00:00
2007-09-29 12:53:16 +00:00
$content = post_str ( " content " , true );
$preview = post_str ( " preview " , true );
if ( post_str ( 'submit' , true ) && ( ! $preview )) {
2007-02-08 19:54:05 +00:00
check_tokens ( $logged_in_user -> getAuthenticator ());
2007-07-08 12:31:13 +00:00
if ( post_str ( 'add_signature' , true ) == " 1 " ){
$add_signature = true ;
} else {
$add_signature = false ;
}
$post -> setSignature ( $add_signature );
2007-09-29 12:53:16 +00:00
$post -> setContent ( $content );
2006-06-16 23:53:56 +00:00
// If this post belongs to the creator of the thread and is at top-level
// (ie. not a response to another post) allow the user to modify the thread title
if ( $can_edit_title ){
$thread -> setTitle ( post_str ( 'title' ));
2004-04-13 23:55:05 +00:00
}
2003-08-14 00:56:20 +00:00
2006-06-16 23:53:56 +00:00
header ( 'Location: forum_thread.php?id=' . $thread -> getID ());
2003-07-19 00:26:18 +00:00
}
2003-08-13 22:08:12 +00:00
2004-05-11 22:49:23 +00:00
page_head ( 'Forum' );
2003-07-19 00:26:18 +00:00
2006-06-16 23:53:56 +00:00
$forum = $thread -> getForum ();
$category = $forum -> getCategory ();
2003-07-19 00:26:18 +00:00
2006-06-16 23:53:56 +00:00
show_forum_title ( $forum , $thread );
2003-07-19 00:26:18 +00:00
2007-09-29 12:53:16 +00:00
if ( $preview == tra ( " Preview " )) {
$options = new output_options ;
echo " <div id= \" preview \" > \n " ;
echo " <div class= \" header \" > " . tra ( " Preview " ) . " </div> \n " ;
echo output_transform ( $content , $options );
echo " </div> \n " ;
}
2006-06-16 23:53:56 +00:00
echo " <form action= \" forum_edit.php?id= " . $post -> getID () . " \" method= \" POST \" > \n " ;
2007-02-08 19:54:05 +00:00
echo form_tokens ( $logged_in_user -> getAuthenticator ());
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 (
tr ( FORUM_SUBMIT_NEW_TITLE ) . html_info (),
" <input type= \" text \" name= \" title \" value= \" " . stripslashes ( htmlspecialchars ( $title )) . " \" > "
);
} else {
row2 (
tr ( FORUM_SUBMIT_NEW_TITLE ) . html_info (),
'<input type="text" name="title" value="' . stripslashes ( htmlspecialchars ( $thread -> getTitle ())) . '">'
);
}
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 (
tr ( FORUM_MESSAGE ) . html_info () . post_warning (),
" <textarea name= \" content \" rows= \" 12 \" cols= \" 80 \" > " . stripslashes ( htmlspecialchars ( $content )) . " </textarea> "
);
} else {
row2 (
tr ( FORUM_MESSAGE ) . html_info () . post_warning (),
'<textarea name="content" rows="12" cols="80">' . stripslashes ( htmlspecialchars ( $post -> getContent ())) . '</textarea>'
);
}
2007-07-08 12:31:13 +00:00
if ( $post -> hasSignature ()) {
$enable_signature = " checked= \" true \" " ;
} else {
$enable_signature = " " ;
}
row2 ( " " , " <input id= \" add_signature \" name= \" add_signature \" value= \" 1 \" " . $enable_signature . " type= \" checkbox \" >
< label for = \ " add_signature \" > " . tr ( FORUM_ADD_MY_SIG ) . " </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
2003-12-04 22:42:51 +00:00
?>