From e56ed1430f151610b49d0afac4c00a356bafe3d6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 2 Feb 2008 17:01:57 +0000 Subject: [PATCH] - 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 --- checkin_notes | 13 ++++++ db/db_base.h | 2 +- html/user/forum_moderate_thread.php | 51 ++++++++++++---------- html/user/forum_moderate_thread_action.php | 21 ++++----- html/user/forum_thread.php | 2 +- 5 files changed, 51 insertions(+), 38 deletions(-) diff --git a/checkin_notes b/checkin_notes index 9b899c4bd6..da0c9b6f38 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/db/db_base.h b/db/db_base.h index fc52461c57..9060a09509 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -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); } diff --git a/html/user/forum_moderate_thread.php b/html/user/forum_moderate_thread.php index 41d21bdc95..858357ad04 100644 --- a/html/user/forum_moderate_thread.php +++ b/html/user/forum_moderate_thread.php @@ -1,44 +1,45 @@ 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 "
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 ""; +$action = get_str('action'); +switch ($action) { +case 'hide': +case 'lock': + echo ""; 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", - ""); -} elseif (get_str('action')=="move") { + "" + ); + break; +case 'move': if ($forum->parent_type != 0) error_page("Nope"); echo ""; $selectbox = '"; - row2("New title:", "title))."\">"); -} else { + row2("New title:", + "title))."\">" + ); + break; +default: error_page("Unknown action"); } row2("Reason
Mailed if nonempty", - ""); + "" +); row2( "", diff --git a/html/user/forum_moderate_thread_action.php b/html/user/forum_moderate_thread_action.php index 0f8431bc92..87045a73ec 100644 --- a/html/user/forum_moderate_thread_action.php +++ b/html/user/forum_moderate_thread_action.php @@ -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"); diff --git a/html/user/forum_thread.php b/html/user/forum_thread.php index c1e4407142..3f3b8e1716 100644 --- a/html/user/forum_thread.php +++ b/html/user/forum_thread.php @@ -140,7 +140,7 @@ if (is_moderator($logged_in_user, $forum)) { if ($thread->locked) { show_button("forum_moderate_thread_action.php?action=unlock&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");