diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php index eb8f91f24d..3428bdfc18 100644 --- a/wp-admin/moderation.php +++ b/wp-admin/moderation.php @@ -4,7 +4,7 @@ require_once('admin.php'); $title = __('Moderate comments'); $parent_file = 'edit.php'; -$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'feelinglucky'); +$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'); for ($i=0; $i $value) { if ($feelinglucky && 'later' == $value) $value = 'delete'; @@ -48,15 +49,17 @@ case 'update': // wp_set_comment_status($key, "hold"); ++$item_ignored; break; - case 'delete': wp_set_comment_status($key, 'delete'); ++$item_deleted; break; - + case 'spam': + wp_set_comment_status($key, 'spam'); + ++$item_spam; + break; case 'approve': wp_set_comment_status($key, 'approve'); - if (get_settings('comments_notify') == true) { + if ( get_settings('comments_notify') == true ) { wp_notify_postauthor($key); } ++$item_approved; @@ -65,7 +68,7 @@ case 'update': } $file = basename(__FILE__); - header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved"); + header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam"); exit(); break; @@ -77,8 +80,9 @@ require_once('admin-header.php'); if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) { echo "
\n

"; $approved = (int) $_GET['approved']; - $deleted = (int) $_GET['deleted']; - $ignored = (int) $_GET['ignored']; + $deleted = (int) $_GET['deleted']; + $ignored = (int) $_GET['ignored']; + $spam = (int) $_GET['spam']; if ($approved) { if ('1' == $approved) { echo __("1 comment approved
") . "\n"; @@ -93,6 +97,13 @@ if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored echo sprintf(__("%s comments deleted
"), $deleted) . "\n"; } } + if ($spam) { + if ('1' == $spam) { + echo __("1 comment marked as spam
") . "\n"; + } else { + echo sprintf(__("%s comments marked as spam
"), $spam) . "\n"; + } + } if ($ignored) { if ('1' == $ignored) { echo __("1 comment unchanged
") . "\n"; @@ -139,6 +150,7 @@ echo 'comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\">" . __('Delete just this comment') . " | "; ?> +

@@ -173,7 +185,14 @@ function markAllForDefer() { } } } -document.write(''); +function markAllAsSpam() { + for (var i=0; i< document.approval.length; i++) { + if (document.approval[i].value == "spam") { + document.approval[i].checked = true; + } + } +} +document.write(''); // ]]> diff --git a/wp-includes/comment-functions.php b/wp-includes/comment-functions.php index da112378f0..773efc785d 100644 --- a/wp-includes/comment-functions.php +++ b/wp-includes/comment-functions.php @@ -568,17 +568,6 @@ function discover_pingback_server_uri($url, $timeout_bytes = 2048) { } -/* wp_set_comment_status: - part of otaku42's comment moderation hack - changes the status of a comment according to $comment_status. - allowed values: - hold : set comment_approve field to 0 - approve: set comment_approve field to 1 - delete : remove comment out of database - - returns true if change could be applied - returns false on database error or invalid value for $comment_status - */ function wp_set_comment_status($comment_id, $comment_status) { global $wpdb; @@ -589,6 +578,9 @@ function wp_set_comment_status($comment_id, $comment_status) { case 'approve': $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1"; break; + case 'spam': + $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1"; + break; case 'delete': $query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"; break; @@ -605,30 +597,21 @@ function wp_set_comment_status($comment_id, $comment_status) { } -/* wp_get_comment_status - part of otaku42's comment moderation hack - gets the current status of a comment - - returned values: - "approved" : comment has been approved - "unapproved": comment has not been approved - "deleted ": comment not found in database - - a (boolean) false signals an error - */ function wp_get_comment_status($comment_id) { - global $wpdb; - - $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); - if ($result == NULL) { - return "deleted"; - } else if ($result == "1") { - return "approved"; - } else if ($result == "0") { - return "unapproved"; - } else { - return false; - } + global $wpdb; + + $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); + if ($result == NULL) { + return 'deleted'; + } else if ($result == '1') { + return 'approved'; + } else if ($result == '0') { + return 'unapproved'; + } else if ($result == 'spam') { + return 'spam'; + } else { + return false; + } } if ( ! function_exists('wp_notify_postauthor') ) {