- DB code: safe_atof() was returning a float,

causing a potential loss of precision.
    Change it to double (same as atof())
- When moderator locks a thread, let them specify reason

svn path=/trunk/boinc/; revision=14662
This commit is contained in:
David Anderson 2008-02-02 17:01:57 +00:00
parent b8877e887e
commit e56ed1430f
5 changed files with 51 additions and 38 deletions

View File

@ -1069,3 +1069,16 @@ David Feb 2 2008
html/user/
am_get_info.php
David Feb 2 2008
- DB code: safe_atof() was returning a float,
causing a potential loss of precision.
Change it to double (same as atof())
- When moderator locks a thread, let them specify reason
db/
db_base.h
html/user/
forum_moderate_thread.php
forum_moderate_thread_action.php
forum_thread.php

View File

@ -33,7 +33,7 @@ inline int safe_atoi(const char* s) {
return atoi(s);
}
inline float safe_atof(const char* s) {
inline double safe_atof(const char* s) {
if (!s) return 0;
return atof(s);
}

View File

@ -1,44 +1,45 @@
<?php
// Where the moderator decides what action to take on a thread. Sends
// its data to forum_moderate_thread_action.php for the actual action to
// take place.
require_once('../inc/forum.inc');
$logged_in_user = get_logged_in_user();
BoincForumPrefs::lookup($logged_in_user);
if (!get_str('action')) {
error_page("You must specify an action...");
error_page("no action");
}
$thread = BoincThread::lookup_id(get_int('thread'));
$forum = BoincForum::lookup_id($thread->forum);
if (!is_moderator($logged_in_user, $forum)) {
error_page("You are not authorized to moderate this post.");
error_page("not authorized");
}
page_head('Forum');
page_head('Moderate');
echo "<form action=forum_moderate_thread_action.php?thread=$thread->id method=POST>\n";
echo form_tokens($logged_in_user->authenticator);
start_table();
row1("Moderate thread");
if (get_str('action')=="hide") {
//display input that selects reason
echo "<input type=hidden name=action value=hide>";
$action = get_str('action');
switch ($action) {
case 'hide':
case 'lock':
echo "<input type=hidden name=action value=$action>";
row2("",
"Select the reason category, or write a longer description of why you're hiding the thread; then press OK to hide it.");
"Select the reason category, or write a longer description of why you're hiding or locking the thread; then press OK."
);
row2("Category",
"<select name=\"category\">
<option value=\"1\">Obscene</option>
<option value=\"2\">Flame/Hate mail</option>
<option value=\"3\">Commercial spam</option>
<option value=\"4\">Other</option>
</select>");
} elseif (get_str('action')=="move") {
"<select name=\"category\">
<option value=\"1\">Obscene</option>
<option value=\"2\">Flame/Hate mail</option>
<option value=\"3\">Commercial spam</option>
<option value=\"4\">Other</option>
</select>"
);
break;
case 'move':
if ($forum->parent_type != 0) error_page("Nope");
echo "<input type=hidden name=action value=move>";
$selectbox = '<select name="forumid">';
@ -52,16 +53,20 @@ if (get_str('action')=="hide") {
$selectbox .= '</option>';
row2("Destination forum:", $selectbox);
} elseif (get_str('action')=="title") {
break;
case 'title':
echo "<input type=hidden name=action value=title>";
row2("New title:", "<input name=\"newtitle\" value=\"".stripslashes(htmlspecialchars($thread->title))."\">");
} else {
row2("New title:",
"<input name=\"newtitle\" value=\"".stripslashes(htmlspecialchars($thread->title))."\">"
);
break;
default:
error_page("Unknown action");
}
row2("Reason<br>Mailed if nonempty",
"<textarea rows=10 cols=80 name=\"reason\"></textarea>");
"<textarea rows=10 cols=80 name=\"reason\"></textarea>"
);
row2(
"",

View File

@ -6,18 +6,15 @@ require_once("../inc/forum_email.inc");
$logged_in_user = get_logged_in_user();
check_tokens($logged_in_user->authenticator);
BoincForumPrefs::lookup($logged_in_user);
if (!post_str('action', true)) {
if (!get_str('action', true)){
error_page("You must specify an action...");
} else {
$action = get_str('action');
}
} else {
$action = post_str('action');
$action = post_str('action', true);
if (!$action) {
$action = get_str('action');
}
$thread = BoincThread::lookup_id(get_int('thread'));
if (!$thread) error_page("no thread");
$forum = BoincForum::lookup_id($thread->forum);
if (!$forum) error_page("no forum");
if (!is_moderator($logged_in_user, $forum)) {
error_page("You are not authorized to moderate this post.");
@ -49,11 +46,9 @@ if ($action=="hide") {
}
if ($result) {
if (post_str('reason', true)){
send_thread_moderation_email($forum, $thread, post_str("reason"),$action);
} else {
send_thread_moderation_email($forum, $thread, "None Given",$action);
}
$reason = post_str('reason', true);
if (!$reason) $reason = "None given";
send_thread_moderation_email($forum, $thread, $reason, $action);
header('Location: forum_thread.php?id='.$thread->id);
} else {
error_page("Moderation failed");

View File

@ -140,7 +140,7 @@ if (is_moderator($logged_in_user, $forum)) {
if ($thread->locked) {
show_button("forum_moderate_thread_action.php?action=unlock&amp;thread=".$thread->id."$tokens", "Unlock", "Unlock this thread");
} else {
show_button("forum_moderate_thread_action.php?action=lock&thread=".$thread->id."$tokens", "Lock", "Lock this thread");
show_button("forum_moderate_thread.php?action=lock&thread=".$thread->id."$tokens", "Lock", "Lock this thread");
}
if ($forum->parent_type == 0) {
show_button("forum_moderate_thread.php?action=move&thread=".$thread->id."$tokens", "Move", "Move this thread to a different forum");