2003-07-19 00:26:18 +00:00
< ? php
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 ();
if ( $logged_in_user -> getID () != $post_owner -> getID ()) {
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
2006-06-16 23:53:56 +00:00
if ( post_str ( 'submit' , true )) {
2003-07-19 00:26:18 +00:00
2006-06-16 23:53:56 +00:00
$post -> setContent ( post_str ( 'content' ));
// 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
2006-06-16 23:53:56 +00:00
echo " <form action= \" forum_edit.php?id= " . $post -> getID () . " \" method= \" POST \" > \n " ;
2003-08-13 22:08:12 +00:00
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
2004-06-07 03:34:07 +00:00
row2 (
2005-09-27 20:53:00 +00:00
tr ( FORUM_SUBMIT_NEW_TITLE ) . html_info (),
2006-06-16 23:53:56 +00:00
" <input type=text name=title value= \" " . stripslashes ( $thread -> getTitle ()) . " \" > "
2004-06-07 03:34:07 +00:00
);
2004-04-13 23:55:05 +00:00
};
2003-08-13 22:08:12 +00:00
2004-06-07 03:34:07 +00:00
row2 (
2005-09-27 20:53:00 +00:00
tr ( FORUM_MESSAGE ) . html_info () . post_warning (),
2006-06-16 23:53:56 +00:00
" <textarea name= \" content \" rows=12 cols=80> " . cleanTextBox ( stripslashes ( $post -> getContent ())) . " </textarea> "
2004-06-07 03:34:07 +00:00
);
row2 (
" " ,
" <input type=submit name=submit value=OK> "
);
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
?>