2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
2014-04-18 22:54:28 +00:00
|
|
|
// Copyright (C) 2014 University of California
|
2008-08-05 22:43:14 +00:00
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-09-29 12:53:16 +00:00
|
|
|
|
2012-07-11 05:27:31 +00:00
|
|
|
// Post a reply to a thread.
|
2007-11-12 20:57:15 +00:00
|
|
|
// Both input (form) and action take place here.
|
|
|
|
|
2014-04-18 22:54:28 +00:00
|
|
|
require_once('../inc/util.inc');
|
2006-07-01 20:03:48 +00:00
|
|
|
require_once('../inc/forum_email.inc');
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once('../inc/forum.inc');
|
2009-06-23 17:15:17 +00:00
|
|
|
require_once('../inc/bbcode_html.inc');
|
2007-04-19 18:22:38 +00:00
|
|
|
require_once('../inc/akismet.inc');
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2014-04-18 22:54:28 +00:00
|
|
|
if (DISABLE_FORUMS) error_page("Forums are disabled");
|
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$logged_in_user = get_logged_in_user(true);
|
|
|
|
BoincForumPrefs::lookup($logged_in_user);
|
2006-08-08 20:32:37 +00:00
|
|
|
check_banished($logged_in_user);
|
2004-09-04 23:37:49 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$thread = BoincThread::lookup_id(get_int('thread'));
|
|
|
|
$forum = BoincForum::lookup_id($thread->forum);
|
2005-04-20 21:11:20 +00:00
|
|
|
|
2005-05-10 16:08:05 +00:00
|
|
|
$sort_style = get_str('sort', true);
|
|
|
|
$filter = get_str('filter', true);
|
2006-06-16 23:53:56 +00:00
|
|
|
$content = post_str('content', true);
|
2007-09-29 12:53:16 +00:00
|
|
|
$preview = post_str("preview", true);
|
2006-06-16 23:53:56 +00:00
|
|
|
$parent_post_id = get_int('post', true);
|
2011-02-09 22:11:34 +00:00
|
|
|
|
2007-10-31 19:26:02 +00:00
|
|
|
$parent_post = null;
|
2007-11-12 20:57:15 +00:00
|
|
|
if ($parent_post_id) {
|
|
|
|
$parent_post = BoincPost::lookup_id($parent_post_id);
|
|
|
|
if ($parent_post->thread != $thread->id) {
|
|
|
|
error_page("wrong thread");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$parent_post_id = 0;
|
|
|
|
}
|
2005-05-10 16:08:05 +00:00
|
|
|
|
|
|
|
if ($filter != "false"){
|
|
|
|
$filter = true;
|
|
|
|
} else {
|
|
|
|
$filter = false;
|
|
|
|
}
|
|
|
|
|
2007-11-15 22:51:05 +00:00
|
|
|
check_reply_access($logged_in_user, $forum, $thread);
|
2005-04-20 21:11:20 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
if (!$sort_style) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$sort_style = $logged_in_user->prefs->thread_sorting;
|
2005-05-10 16:08:05 +00:00
|
|
|
} else {
|
2007-11-12 20:57:15 +00:00
|
|
|
$logged_in_user->prefs->update("thread_sorting=$sort_style");
|
2005-05-10 16:08:05 +00:00
|
|
|
}
|
2005-04-20 21:11:20 +00:00
|
|
|
|
2008-10-09 18:28:55 +00:00
|
|
|
$warning = null;
|
2007-09-29 12:53:16 +00:00
|
|
|
if ($content && (!$preview)){
|
2006-06-16 23:53:56 +00:00
|
|
|
if (post_str('add_signature',true)=="add_it"){
|
2005-02-13 06:13:33 +00:00
|
|
|
$add_signature=true; // set a flag and concatenate later
|
2004-10-10 03:04:29 +00:00
|
|
|
} else {
|
2005-02-13 06:13:33 +00:00
|
|
|
$add_signature=false;
|
2004-10-10 03:04:29 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
check_tokens($logged_in_user->authenticator);
|
2008-10-09 18:28:55 +00:00
|
|
|
if (!akismet_check($logged_in_user, $content)) {
|
2011-08-25 22:12:48 +00:00
|
|
|
$warning = tra("Your post has been flagged as spam by the Akismet anti-spam system. Please modify your text and try again.");
|
2008-10-09 18:28:55 +00:00
|
|
|
$preview = tra("Preview");
|
|
|
|
} else {
|
2012-08-01 17:57:56 +00:00
|
|
|
$post_id = create_post(
|
2008-10-09 18:28:55 +00:00
|
|
|
$content, $parent_post_id, $logged_in_user, $forum,
|
|
|
|
$thread, $add_signature
|
|
|
|
);
|
2012-08-01 17:57:56 +00:00
|
|
|
if ($post_id) {
|
|
|
|
header("Location: forum_thread.php?id=$thread->id&postid=$post_id");
|
|
|
|
} else {
|
|
|
|
error_page("Can't create post.");
|
|
|
|
}
|
2008-10-09 18:28:55 +00:00
|
|
|
}
|
2003-07-18 21:38:51 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 17:13:35 +00:00
|
|
|
page_head(tra("Post to thread"),'','','', $bbcode_js);
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2007-11-15 00:27:02 +00:00
|
|
|
show_forum_header($logged_in_user);
|
2007-11-16 21:48:28 +00:00
|
|
|
|
2010-01-29 17:00:14 +00:00
|
|
|
if ($warning) {
|
2014-10-02 19:15:54 +00:00
|
|
|
echo "<p class=\"text-danger\">$warning</p>";
|
2010-01-29 17:00:14 +00:00
|
|
|
}
|
|
|
|
|
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:
|
2007-11-26 04:12:15 +00:00
|
|
|
show_team_forum_title($forum, $thread);
|
2007-11-16 21:48:28 +00:00
|
|
|
break;
|
2007-11-15 22:51:05 +00:00
|
|
|
}
|
2007-11-23 21:05:52 +00:00
|
|
|
echo "<p>";
|
2007-09-29 12:53:16 +00:00
|
|
|
|
|
|
|
if ($preview == tra("Preview")) {
|
|
|
|
$options = new output_options;
|
2014-08-27 21:27:55 +00:00
|
|
|
if (is_admin($logged_in_user)) {
|
|
|
|
$options->htmlitems = false;
|
|
|
|
}
|
2011-02-14 19:49:30 +00:00
|
|
|
echo "<h2>".tra("Preview")."</h2>\n";
|
2011-02-13 23:57:39 +00:00
|
|
|
echo "<div class=\"pm_preview\">"
|
|
|
|
.output_transform($content, $options)
|
|
|
|
."</div>\n"
|
|
|
|
;
|
2007-09-29 12:53:16 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 21:10:38 +00:00
|
|
|
start_table();
|
2006-06-16 23:53:56 +00:00
|
|
|
show_message_row($thread, $parent_post);
|
2012-07-13 21:10:38 +00:00
|
|
|
end_table();
|
2012-07-11 19:24:28 +00:00
|
|
|
if ($parent_post) {
|
2012-07-13 21:10:38 +00:00
|
|
|
start_forum_table(array(tra("Author"), tra("Message")));
|
2012-07-11 19:24:28 +00:00
|
|
|
show_post(
|
|
|
|
$parent_post, $thread, $forum, $logged_in_user, 0, 0, false, false
|
|
|
|
);
|
2012-07-13 21:10:38 +00:00
|
|
|
end_table();
|
|
|
|
} else {
|
|
|
|
show_posts($thread, $forum, 0, 0, CREATE_TIME_NEW, 0, $logged_in_user);
|
2012-07-11 19:24:28 +00:00
|
|
|
}
|
2012-07-13 21:10:38 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
end_table();
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-15 01:01:00 +00:00
|
|
|
page_tail();
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
function show_message_row($thread, $parent_post) {
|
2011-04-26 21:38:22 +00:00
|
|
|
global $logged_in_user, $bbcode_html;
|
2009-06-23 17:18:29 +00:00
|
|
|
global $content, $preview;
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2011-08-25 22:12:48 +00:00
|
|
|
$x1 = tra("Message:").html_info().post_warning();
|
2005-02-16 00:24:53 +00:00
|
|
|
$x2 = "";
|
2006-06-16 23:53:56 +00:00
|
|
|
if ($parent_post) {
|
2011-08-25 22:12:48 +00:00
|
|
|
$x2 .=" ".tra("reply to %1Message ID%2:", "<a href=#".$parent_post->id.">", " ".$parent_post->id."</a>");
|
2003-12-01 06:08:22 +00:00
|
|
|
}
|
2007-11-12 20:57:15 +00:00
|
|
|
$x2 .= "<form action=forum_reply.php?thread=".$thread->id;
|
2003-07-24 22:56:20 +00:00
|
|
|
|
2006-06-16 23:53:56 +00:00
|
|
|
if ($parent_post) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$x2 .= "&post=".$parent_post->id;
|
2003-07-24 22:56:20 +00:00
|
|
|
}
|
2003-08-22 19:09:32 +00:00
|
|
|
|
2009-06-23 16:37:13 +00:00
|
|
|
$x2 .= " method=\"post\" name=\"post\" onsubmit=\"return checkForm(this)\">\n";
|
2011-04-26 21:38:22 +00:00
|
|
|
$x2 .= form_tokens($logged_in_user->authenticator);
|
2010-11-04 18:20:57 +00:00
|
|
|
$x2 .= $bbcode_html."<textarea name=\"content\" rows=\"18\" cols=\"80\">";
|
2008-09-25 12:56:42 +00:00
|
|
|
$no_quote = get_int("no_quote", true)==1;
|
2007-09-29 12:53:16 +00:00
|
|
|
if ($preview) {
|
2008-06-05 20:32:21 +00:00
|
|
|
$x2 .= htmlspecialchars($content);
|
2008-09-25 12:56:42 +00:00
|
|
|
} else if (!$no_quote) {
|
2012-07-13 21:10:38 +00:00
|
|
|
if ($parent_post) {
|
|
|
|
$x2 .= quote_text(htmlspecialchars($parent_post->content))."\n";
|
|
|
|
}
|
2007-09-29 12:53:16 +00:00
|
|
|
}
|
2011-08-25 22:12:48 +00:00
|
|
|
if (!$logged_in_user->prefs->no_signature_by_default) {
|
2005-02-16 00:24:53 +00:00
|
|
|
$enable_signature="checked=\"true\"";
|
|
|
|
} else {
|
|
|
|
$enable_signature="";
|
|
|
|
}
|
2007-09-29 12:53:16 +00:00
|
|
|
$x2 .= "</textarea><p>
|
2014-10-02 19:15:54 +00:00
|
|
|
<input class=\"btn btn-default\" type=\"submit\" name=\"preview\" value=\"".tra("Preview")."\">
|
|
|
|
<input class=\"btn btn-primary\" type=\"submit\" value=\"".tra("Post reply")."\">
|
2003-11-28 22:35:01 +00:00
|
|
|
|
2011-08-25 22:12:48 +00:00
|
|
|
<input type=\"checkbox\" name=\"add_signature\" id=\"add_signature\" value=\"add_it\" ".$enable_signature.">
|
|
|
|
<label for=\"add_signature\">".tra("Add my signature to this reply")."</label>
|
2003-11-28 22:35:01 +00:00
|
|
|
|
2003-12-01 06:08:22 +00:00
|
|
|
</form>
|
2005-02-13 06:13:33 +00:00
|
|
|
";
|
2005-02-16 00:24:53 +00:00
|
|
|
row2($x1, $x2);
|
2003-07-24 22:56:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 18:20:57 +00:00
|
|
|
function quote_text($text) {
|
2005-05-13 19:14:19 +00:00
|
|
|
$text = "[quote]" . $text . "[/quote]";
|
2005-04-28 09:32:22 +00:00
|
|
|
return $text;
|
2003-07-26 00:19:21 +00:00
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
$cvs_version_tracker[]="\$Id$";
|
2003-11-28 22:35:01 +00:00
|
|
|
?>
|