From a054467f9bba8b53875fe5451e039a691713855a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 6 Jul 2008 22:30:10 +0000 Subject: [PATCH] - web: include "reason" field in emails for thread moderation svn path=/trunk/boinc/; revision=15553 --- checkin_notes | 14 ++++- doc/index.php | 4 +- html/inc/forum_email.inc | 52 ++++++++--------- html/user/forum_moderate_thread.php | 12 ++-- html/user/forum_moderate_thread_action.php | 68 +++++++++++++++++----- 5 files changed, 96 insertions(+), 54 deletions(-) diff --git a/checkin_notes b/checkin_notes index 4046c2b500..28b04a1330 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5193,7 +5193,7 @@ David 26 June 2008 David 26 June 2008 - back-end code: fix compiler warnings (and maybe bugs); - to some retentive code cleanup + do some retentive code cleanup sched/ feeder.C @@ -5307,7 +5307,7 @@ David 1 July 2008 handle_request.C server_types.C -Eric 1 July 2008 +Eric 1 July 2008 - client: Fixes ticket Fixes ticket #537. Forces use of small files in zlib.h and when /proc filesystem is used on solaris. @@ -5488,3 +5488,13 @@ David 4 July 2008 util.inc user/ create_profile.php + +David 6 July 2008 + - web: include "reason" field in emails for thread moderation + + html/ + inc/ + forum_email.inc + user/ + forum_moderate_thread.php + forum_modearte_thread_action.php diff --git a/doc/index.php b/doc/index.php index 67115549b9..38a8e75ca9 100644 --- a/doc/index.php +++ b/doc/index.php @@ -126,8 +126,8 @@ function show_create() {
And check out: "; diff --git a/html/inc/forum_email.inc b/html/inc/forum_email.inc index 626fff62ed..dd7ddd08e6 100644 --- a/html/inc/forum_email.inc +++ b/html/inc/forum_email.inc @@ -52,13 +52,13 @@ function send_moderation_email($forum, $post, $thread, $explanation, $action) { $subject = PROJECT." moderation notice"; - $body = "Your post [ID $post->id] in thread \"$thread->title\" + $body = "Your post [ID $post->id] in thread '$thread->title' ".URL_BASE."forum_thread.php?id=$thread->id#$post->id has been $action by moderator $moderator->name (ID $moderator->id). $explanation The content of your post: -".$post->content." +$post->content For further information and assistance with ".PROJECT." go to ".MASTER_URL; @@ -72,34 +72,31 @@ Subject: $subject $body "; - $subject = PROJECT.": post $action in \"$thread->title\""; + $subject = PROJECT.": post $action in '$thread->title'"; $success &= mail_report_list($forum, $subject, $body); return $success; } //////////////////// thread hidden/unhidden /////////// // -function send_thread_moderation_email($forum, $thread, $message, $action) { - $moderator=get_logged_in_user(); +function send_thread_moderation_email( + $forum, $thread, $message, $action_name, $explanation +) { + $moderator = get_logged_in_user(); $user = BoincUser::lookup_id($thread->owner); $body = ""; $subject = PROJECT." forum moderation notice"; - $body = PROJECT." notification: - -This email is sent to inform you that one of your threads in the forum has been affected by moderation in ".PROJECT.": - Thread: ".$thread->title." - Link: ".MASTER_URL."forum_thread.php?id=".$thread->id." - Moderator: ".$moderator->name." (".$moderator->id.") - Action: ".$action." - -The moderator gave this explanation to why your thread was moderated: -".$message; -$body .= " + $body = "Your thread '$thread->title' +".URL_BASE."forum_thread.php?id=$thread->id +has been $action_name +by moderator $moderator->name (ID $moderator->id). +$explanation For further information and assistance with ".PROJECT." go to ".MASTER_URL; - $success = mail_report_list($forum, "THREAD ".$action." REPORT: ".$thread->title, $body); + $subject = "THREAD $action REPORT: $thread->title"; + $success = mail_report_list($forum, $subject, $body); $success &= send_email($user, $subject, $body); return $success; } @@ -128,20 +125,20 @@ function send_report_post_email($user, $forum, $thread, $post, $message) { $body = ""; $owner = BoincUser::lookup_id($post->user); - $subject = PROJECT." post in '".$thread->title."' reported as offensive"; + $subject = PROJECT." post in '$thread->title' reported as offensive"; $body = PROJECT." notification: -This email is sent to inform you that one of the posts in the forum was reported as offensive in ".PROJECT.": - Thread: ".$thread->title." - Post: ".$post->id." by ".$owner->id." (".$owner->name.") - Reporting User: ".$user->id." (".$user->name.") - Link: ".URL_BASE."forum_thread.php?id=".$thread->id."#".$post->id." +A post in the ".PROJECT." forums was reported as offensive. + Thread: $thread->title + Post: $post->id by $owner->id ($owner->name) + Reporting User: $user->id ($user->name) + Link: ".URL_BASE."forum_thread.php?id=$thread->id#$post->id -The reporting user gave this explanation to why the post was reported: -".$message." +Comments from reporting user: +$message -This was the contents of the post: -".$post->content." +Contents of the post: +$post->content For further information and assistance with ".PROJECT." go to ".MASTER_URL; @@ -209,5 +206,4 @@ able to resume posting at that time. $success &= mail_report_list($forum, "A banishment vote for ".$user->name." has been started.", $body); return $success; } - ?> diff --git a/html/user/forum_moderate_thread.php b/html/user/forum_moderate_thread.php index 72708f3d5c..22521bb5b5 100644 --- a/html/user/forum_moderate_thread.php +++ b/html/user/forum_moderate_thread.php @@ -15,12 +15,11 @@ if (!is_moderator($logged_in_user, $forum)) { error_page("not authorized"); } -page_head('Moderate'); +page_head("Moderate thread '$thread->title'"); echo "
id method=POST>\n"; echo form_tokens($logged_in_user->authenticator); start_table(); -row1("Moderate thread"); $action = get_str('action'); switch ($action) { @@ -46,13 +45,14 @@ case 'move': $categories = BoincCategory::enum(); foreach ($categories as $category) { $forums = BoincForum::enum("category=$category->id"); - foreach ($forums as $forum) { - $selectbox .= ''; + foreach ($forums as $f) { + $selectbox .= ''; } } $selectbox .= ''; - row2("Destination forum:", $selectbox); + row2("Current forum", $forum->title); + row2("Destination forum", $selectbox); break; case 'title': echo ""; @@ -64,7 +64,7 @@ default: error_page("Unknown action"); } -row2("Reason
Mailed if nonempty", +row2("Reason
Mailed if nonempty", "" ); diff --git a/html/user/forum_moderate_thread_action.php b/html/user/forum_moderate_thread_action.php index 87045a73ec..b32f306ccf 100644 --- a/html/user/forum_moderate_thread_action.php +++ b/html/user/forum_moderate_thread_action.php @@ -20,38 +20,74 @@ if (!is_moderator($logged_in_user, $forum)) { error_page("You are not authorized to moderate this post."); } -if ($action=="hide") { - $cat = post_int("category"); // TODO - store this somewhere +$explanation = ""; +$cat = post_int("category", true); +if ($cat) { + $explanation .= "Reason: "; + switch ($cat) { + case 1: $explanation .= "obscene"; break; + case 2: $explanation .= "flame/hate mail"; break; + case 3: $explanation .= "commercial spam"; break; + case 4: $explanation .= "other"; break; + } + $explanation .= "\n"; +} + +$comment = post_str('reason', true); +if ($comment) { + $explanation .= "Moderator comment: $comment\n"; +} + +switch ($action) { +case "hide": $result = hide_thread($thread, $forum); -} elseif ($action=="unhide"){ + $action_name = "hidden"; + break; +case "unhide": $result = unhide_thread($thread, $forum); -} elseif ($action=="sticky"){ + $action_name = "unhidden"; + break; +case "sticky": $result = $thread->update("sticky=1"); -} elseif ($action=="desticky"){ + $action_name = "made sticky"; + break; +case "desticky": $result = $thread->update("sticky=0"); -} elseif ($action == "lock") { + $action_name = "made non-sticky"; + break; +case "lock": $result = $thread->update("locked=1"); -} elseif ($action == "unlock") { + $action_name = "locked"; + break; +case "unlock": $result = $thread->update("locked=0"); -} elseif ($action=="move"){ + $action_name = "unlocked"; + break; +case "move": if ($forum->parent_type != 0) error_page("No"); $fid = post_int('forumid'); $new_forum = BoincForum::lookup_id($fid); $result = move_thread($thread, $forum, $new_forum); -} elseif ($action=="title"){ + $action_name = "moved from $forum->title to $new_forum->title"; + break; +case "title": $title = post_str('newtitle'); $result = $thread->update("title='$title'"); -} else { + $action_name = "renamed from '$thread->title' to '$title'"; + break; +default: error_page("Unknown action "); } -if ($result) { - $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 { +if (!$result) { error_page("Moderation failed"); } +$reason = post_str('reason', true); +if (!$reason) $reason = "None given"; +send_thread_moderation_email( + $forum, $thread, $reason, $action_name, $explanation +); +header('Location: forum_thread.php?id='.$thread->id); + ?>