2003-07-19 00:26:18 +00:00
|
|
|
<?php
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once('../inc/forum.inc');
|
|
|
|
require_once('../inc/util.inc');
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2004-12-27 03:42:11 +00:00
|
|
|
db_init();
|
|
|
|
|
2004-04-13 23:55:05 +00:00
|
|
|
$logged_in_user = get_logged_in_user();
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2005-05-12 14:57:16 +00:00
|
|
|
// decorate object with forum preference info (uses DB)
|
|
|
|
// needed to see if user is 'special'.
|
|
|
|
$logged_in_user = getForumPreferences($logged_in_user);
|
|
|
|
|
|
|
|
// if user is a project admin or project developer or forum admin,
|
|
|
|
// allow them to edit their own posts indefinitely.
|
|
|
|
$is_spec = isSpecialUser($logged_in_user,0) ||
|
|
|
|
isSpecialUser($logged_in_user,1) ||
|
|
|
|
isSpecialUser($logged_in_user,2);
|
|
|
|
|
2005-02-13 21:33:02 +00:00
|
|
|
$postid = get_int("id");
|
|
|
|
$post = getPost($postid);
|
|
|
|
if (!$post) {
|
|
|
|
error_page("No such post");
|
|
|
|
}
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
if ($_POST['submit']) {
|
2003-07-19 00:26:18 +00:00
|
|
|
$thread = getThread($post->thread);
|
2004-04-13 23:55:05 +00:00
|
|
|
|
2005-05-12 14:57:16 +00:00
|
|
|
if (!$is_spec && (time() > $post->timestamp + MAXIMUM_EDIT_TIME)){
|
2005-04-20 21:11:20 +00:00
|
|
|
echo "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.";
|
2005-01-18 13:00:38 +00:00
|
|
|
exit();
|
|
|
|
}
|
2004-04-13 23:55:05 +00:00
|
|
|
if ($logged_in_user->id != $post->user) {
|
2005-05-13 19:14:19 +00:00
|
|
|
//if (!(isSpecialUser($logged_in_user,0)) && ($logged_in_user->id != $post->user)) {
|
|
|
|
// Can't edit other's posts unless you're a moderator
|
2004-04-13 23:55:05 +00:00
|
|
|
echo "You are not authorized to edit this post.";
|
|
|
|
exit();
|
|
|
|
}
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2005-01-18 13:00:38 +00:00
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
updatePost($post->id, $_POST['content']);
|
2004-04-17 22:52:16 +00:00
|
|
|
if ($post->parent_post==0 and $thread->owner==$logged_in_user->id){
|
2004-04-13 23:55:05 +00:00
|
|
|
updateThread($thread->id, $_POST['title']);
|
|
|
|
}
|
2003-08-14 00:56:20 +00:00
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
header('Location: forum_thread.php?id='.$thread->id);
|
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
|
|
|
|
2005-02-13 06:13:33 +00:00
|
|
|
$thread = getThread($post->thread);
|
|
|
|
$forum = getForum($thread->forum);
|
|
|
|
$category = getCategory($forum->category);
|
2005-05-12 14:57:16 +00:00
|
|
|
if (!$is_spec && (time() > $post->timestamp + MAXIMUM_EDIT_TIME)){
|
2005-04-20 21:11:20 +00:00
|
|
|
echo "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.";
|
2005-01-18 13:00:38 +00:00
|
|
|
exit();
|
2005-02-13 06:13:33 +00:00
|
|
|
}
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2003-07-19 00:26:18 +00:00
|
|
|
if ($logged_in_user->id != $post->user) {
|
2005-05-13 19:14:19 +00:00
|
|
|
//if (!(isSpecialUser($logged_in_user,0)) && ($logged_in_user->id != $post->user)) {
|
|
|
|
// Can't edit other's posts unless you're a moderator
|
2003-07-19 00:26:18 +00:00
|
|
|
echo "You are not authorized to edit this post.";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
show_forum_title($forum, $thread, $category->is_helpdesk);
|
2003-07-19 00:26:18 +00:00
|
|
|
|
2004-06-01 18:55:59 +00:00
|
|
|
echo "<form action=forum_edit.php?id=$post->id 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");
|
2004-04-17 22:52:16 +00:00
|
|
|
if ($post->parent_post==0 and $thread->owner==$logged_in_user->id) {
|
2004-04-13 23:55:05 +00:00
|
|
|
//If this is the first post enable the user to change title
|
2004-06-07 03:34:07 +00:00
|
|
|
row2(
|
|
|
|
"Thread title",
|
|
|
|
"<input type=text name=title value=\"".stripslashes($thread->title)."\">"
|
|
|
|
);
|
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(
|
|
|
|
"Message content",
|
2005-05-08 01:33:03 +00:00
|
|
|
"<textarea name=\"content\" rows=12 cols=80>".cleanTextBox(stripslashes($post->content))."</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
|
|
|
?>
|