Index: comment.php
===================================================================
--- comment.php	(revision 12600)
+++ comment.php	(working copy)
@@ -35,6 +35,7 @@
  * @param string $msg Error Message. Assumed to contain HTML and be sanitized.
  */
 function comment_footer_die( $msg ) {
+	global $hook_suffix;
 	echo "<div class='wrap'><p>$msg</p></div>";
 	include('admin-footer.php');
 	die;
@@ -70,22 +71,36 @@
 case 'trash'   :
 case 'spam'    :
 
+	$comment_id = absint( $_GET['c'] );
+
+	if ( !$comment = get_comment_to_edit( $comment_id ) ) {
+		wp_redirect( admin_url('edit-comments.php?error=id') );
+		die();
+	}
+
+	if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
+		wp_redirect( admin_url('edit-comments.php?error=cap') );
+		die();
+	}
+
+	if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
+		wp_redirect( admin_url("edit-comments.php?same=$comment_id&p=" . absint( $comment->comment_post_ID ) ) );
+		die();
+	}
+
 	require_once('admin-header.php');
-
-	$comment_id = absint( $_GET['c'] );
 	$formaction    = $action . 'comment';
 	$nonce_action  = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
 	$nonce_action .= $comment_id;
 
-	if ( !$comment = get_comment_to_edit( $comment_id ) )
-		comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
-
-	if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
-		comment_footer_die( 'approve' != $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
 ?>
 <div class='wrap'>
 
 <div class="narrow">
+
+<?php screen_icon(); ?>
+<h2><?php _e( 'Moderate Comment' ); ?></h2>
+
 <?php
 switch ( $action ) {
 	case 'spam' :
@@ -105,8 +120,28 @@
 		$button      = __('Approve Comment');
 		break;
 }
+
+if ( $comment->comment_approved != '0' ) { // if not unapproved
+	switch ( $comment->comment_approved ) {
+		case '1':
+			$message  = __('This comment is currently approved.');
+			break;
+		case 'spam':
+			$message  = __('This comment is currently marked as spam.');
+			break;
+		case 'trash':
+			$message  = __('This comment is currently in the Trash.');
+			break;
+	}
 ?>
 
+	<div class="updated">
+		<p><?php echo $message; ?></p>
+	</div>
+<?php
+}
+?>
+
 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
 
 <table class="form-table comment-ays">
@@ -155,13 +190,19 @@
 <?php
 	break;
 
-case 'deletecomment' :
-case 'trashcomment' :
-case 'untrashcomment' :
-case 'spamcomment' :
-case 'unspamcomment' :
+case 'deletecomment'    :
+case 'trashcomment'     :
+case 'untrashcomment'   :
+case 'spamcomment'      :
+case 'unspamcomment'    :
+case 'approvecomment'   :
+case 'unapprovecomment' :
+
 	$comment_id = absint( $_REQUEST['c'] );
-	check_admin_referer( 'delete-comment_' . $comment_id );
+	if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
+		check_admin_referer( 'approve-comment_' . $comment_id );
+	else
+		check_admin_referer( 'delete-comment_' . $comment_id );
 
 	$noredir = isset($_REQUEST['noredir']);
 
@@ -170,12 +211,12 @@
 	if ( !current_user_can('edit_post', $comment->comment_post_ID ) )
 		comment_footer_die( __('You are not allowed to edit comments on this post.') );
 
-	if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') )
+	if ( '' != wp_get_referer() && false == $noredir && false === strpos( wp_get_referer(), 'comment.php' ) )
 		$redir = wp_get_referer();
 	elseif ( '' != wp_get_original_referer() && false == $noredir )
 		$redir = wp_get_original_referer();
 	else
-		$redir = admin_url('edit-comments.php');
+		$redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
 
 	$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir );
 
@@ -199,7 +240,14 @@
 		case 'unspamcomment' :
 			wp_unspam_comment($comment_id);
 			$redir = add_query_arg( array('unspammed' => '1'), $redir );
-			break;
+		break;
+		case 'approvecomment' :
+			wp_set_comment_status( $comment_id, 'approve' );
+			$redir = add_query_arg( array( 'approved' => 1 ), $redir );
+		break;
+		case 'unapprovecomment' :
+			wp_set_comment_status( $comment_id, 'hold' );
+			$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
 	}
 
 	wp_redirect( $redir );
@@ -207,41 +255,6 @@
 	die;
 	break;
 
-case 'approvecomment'   :
-case 'unapprovecomment' :
-	$comment_id = absint( $_GET['c'] );
-	check_admin_referer( 'approve-comment_' . $comment_id );
-
-	$noredir = isset( $_GET['noredir'] );
-
-	if ( !$comment = get_comment( $comment_id ) )
-		comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
-
-	if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
-		if ( 'approvecomment' == $action )
-			comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
-		else
-			comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
-	}
-
-	if ( '' != wp_get_referer() && false == $noredir )
-		$redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() );
-	else
-		$redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
-
-	if ( 'approvecomment' == $action ) {
-		wp_set_comment_status( $comment_id, 'approve' );
-		$redir = add_query_arg( array( 'approved' => 1 ), $redir );
-	} else {
-		wp_set_comment_status( $comment_id, 'hold' );
-		$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
-	}
-
-	wp_redirect( $redir );
-
-	exit();
-	break;
-
 case 'editedcomment' :
 
 	$comment_id = absint( $_POST['comment_ID'] );
Index: edit-comments.php
===================================================================
--- edit-comments.php	(revision 12600)
+++ edit-comments.php	(working copy)
@@ -126,45 +126,79 @@
 </h2>
 
 <?php
-if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) ) {
-	$approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0;
-	$deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0;
-	$trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0;
-	$untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0;
-	$spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0;
-	$unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0;
+if ( isset( $_GET['error'] ) ) {
+	switch ( $_GET['error'] ) {
+		case 'id' :
+			$error_message = __('Oops, no comment with this ID.');
+			break;
+		case 'cap' :
+			$error_message = __('You are not allowed to edit comments on this post.');
+			break;
+	}
+	
+	if ( isset( $error_message ) ) { ?>
+	<div id="moderated" class="error"><p><?php echo $error_message; ?></p></div>
+	<?php }
+}
 
-	if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 ) {
-		echo '<div id="moderated" class="updated"><p>';
+if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) || isset($_GET['same']) ) {
+	$approved  = isset( $_GET['approved']  ) ? (int) $_GET['approved']  : 0;
+	$deleted   = isset( $_GET['deleted']   ) ? (int) $_GET['deleted']   : 0;
+	$trashed   = isset( $_GET['trashed']   ) ? (int) $_GET['trashed']   : 0;
+	$untrashed = isset( $_GET['untrashed'] ) ? (int) $_GET['untrashed'] : 0;
+	$spammed   = isset( $_GET['spammed']   ) ? (int) $_GET['spammed']   : 0;
+	$unspammed = isset( $_GET['unspammed'] ) ? (int) $_GET['unspammed'] : 0;
+	$same      = isset( $_GET['same']      ) ? (int) $_GET['same']      : 0;
 
-		if ( $approved > 0 ) {
-			printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
-			echo '<br />';
-		}
+	if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
+		$messages = array();
+
+		if ( $approved > 0 )
+			$messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
+
 		if ( $spammed > 0 ) {
-			printf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed );
 			$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
-			echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
+			$messages[]  = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a>';
 		}
-		if ( $unspammed > 0 ) {
-			printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
-			echo '<br />';
-		}
+
+		if ( $unspammed > 0 )
+			$messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
+
 		if ( $trashed > 0 ) {
-			printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed );
 			$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
-			echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
+			$messages[]  = sprintf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a>';
 		}
-		if ( $untrashed > 0 ) {
-			printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed );
-			echo '<br />';
+
+		if ( $untrashed > 0 )
+			$messages[] = sprintf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed );
+
+		if ( $deleted > 0 )
+			$messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
+
+		if ( $same > 0 ) {
+			if ( $comment = get_comment( $same ) ) {
+				switch ( $comment->comment_approved ) {
+					case '1' :
+						$message_same = __( 'This comment is already approved.' );
+						break;
+					case 'trash' :
+						$message_same  = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
+						break;
+					case 'spam' :
+						$message_same = __( 'This comment is already marked as spam.' );
+						break;
+				}
+				if ( isset($message_same) && in_array( $comment->comment_approved, array( '1', 'spam' ) ) )
+					$messages[] = $message_same . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>' ;
+			}
 		}
-		if ( $deleted > 0 ) {
-			printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
-			echo '<br />';
+		if ( sizeof( $messages ) > 0 ) {
+?>
+<div id="moderated" class="updated"><p>
+<?php echo implode( "<br/>\n", $messages ); ?>
+</p></div>
+<?php
 		}
-
-		echo '</p></div>';
 	}
 }
 ?>
