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
|
|
|
|
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");
|
2007-11-15 22:51:05 +00:00
|
|
|
$forum = BoincForum::lookup_id($thread->forum);
|
2006-06-16 23:53:56 +00:00
|
|
|
|
2007-11-15 22:51:05 +00:00
|
|
|
if (!is_moderator($logged_in_user, $forum)) {
|
|
|
|
if (time() > $post->timestamp + 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."
|
|
|
|
);
|
|
|
|
}
|
2006-06-16 23:53:56 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
|
|
|
|
$post_owner = BoincUser::lookup_id($post->user);
|
2007-11-15 22:51:05 +00:00
|
|
|
if (($logged_in_user->id != $post_owner->id) || (can_reply($thread, $forum, $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);
|
2007-11-23 00:51:01 +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
|
|
|
|
//
|
2007-11-12 20:57:15 +00:00
|
|
|
$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-23 00:51:01 +00:00
|
|
|
$add_signature = (post_str('add_signature', true) == "1")?1:0;
|
2007-11-12 20:57:15 +00:00
|
|
|
$content = substr($content, 0, 64000);
|
2007-11-23 00:51:01 +00:00
|
|
|
$content = trim($content);
|
|
|
|
if (strlen($content)) {
|
|
|
|
$content = BoincDb::escape_string($content);
|
|
|
|
$now = time();
|
|
|
|
$post->update("signature=$add_signature, content='$content', modified=$now");
|
2007-07-08 12:31:13 +00:00
|
|
|
|
2007-11-23 00:51:01 +00:00
|
|
|
if ($can_edit_title){
|
|
|
|
$title = trim($title);
|
|
|
|
$title = strip_tags($title);
|
|
|
|
$title = BoincDb::escape_string($title);
|
|
|
|
$thread->update("title='$title'");
|
|
|
|
}
|
|
|
|
header("Location: forum_thread.php?id=$thread->id");
|
|
|
|
} else {
|
|
|
|
delete_post($post, $thread, $forum);
|
|
|
|
header("Location: forum_forum.php?id=$forum->id");
|
2004-04-13 23:55:05 +00:00
|
|
|
}
|
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-15 00:27:02 +00:00
|
|
|
show_forum_header($logged_in_user);
|
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, $thread);
|
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-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();
|
2007-11-15 22:51:05 +00:00
|
|
|
row1("Edit your message");
|
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
|
|
|
?>
|