Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 21781)
+++ wp-includes/comment.php	(working copy)
@@ -2021,3 +2021,173 @@
 
 	return $open;
 }
+
+
+/**
+ * Prints the html for the comment meta box
+ *
+ * @uses get_comment_history() to get comment meta
+ * @param  Object $comment WP comment object
+ * @return void
+ */
+
+//
+// Comment History
+//
+
+/**
+ * Add a history entry to a comment with a messaged tailored to the event being recorded.
+ *
+ * @global object $current_user the current logged in user, if any
+ * @param int $comment_id the id of the comment to add a history entry
+ * @param string $status optional comment status string
+ * @return type
+ */
+function _wp_update_comment_history( $comment_id, $status = '' ) {
+
+	global $current_user;
+
+	// some hooks pass in the comment object, not just the id
+	// in those cases we get the id from the object
+	if( is_object( $comment_id ) )
+		$comment_id = $comment_id->comment_ID;
+
+	$action = current_filter();				// what action happened that we will log as an event in the comment's history?
+	$current_user_login = 'anonymous user'; // what is the name of this user for the comment's history? 'anonymous user' by default.
+	$message = '';							// what message should we log in the comment's history?
+
+	// no action or no comment id then we can't log history and must stop
+	if( ! $action || ! $comment_id )
+		return;
+
+	// get the current logged in user's login name for the history message
+	if ( is_object($current_user) && isset($current_user->user_login) )
+		$current_user_login = $current_user->user_login;
+
+	// create a custom message for the comment history based on the action ( the hook )
+	if( 'edit_comment' === $action )
+		$message = sprintf( __( "edited by %s" ), $current_user_login );
+	elseif( 'trashed_comment' === $action )
+		$message = sprintf( __( "trashed by %s" ), $current_user_login );
+	elseif( 'untrashed_comment' === $action )
+		$message = sprintf( __( "untrashed by %s" ), $current_user_login );
+	elseif( 'comment_unapproved_to_approved' === $action )
+		$message = sprintf( __( "%s approved this comment" ), $current_user_login );
+	elseif( 'comment_approved_to_unapproved' === $action )
+		$message = sprintf( __( "%s unapproved this comment" ), $current_user_login );
+	elseif( 'spammed_comment' === $action )
+		$message = sprintf( __( "%s marked this comment as spam" ), $current_user_login );
+	elseif( 'unspammed_comment' === $action )
+		$message = sprintf( __( "%s marked this comment as ham" ), $current_user_login );
+	else
+		$message = sprintf( __( "%s by %s" ), str_replace( '_', ' ', $action ), $current_user_login ); // default message is based on the hook name
+
+	// insert the history message into comment meta and return result
+
+	$r = false;
+
+	if( $message ) {
+		$entry = array(
+			'time' => time(),
+			'message' => $message,
+			'event' => $action,
+			'user' => $current_user_login,
+		);
+
+		$r = add_comment_meta( $comment_id, '_wp_history', $entry, false );
+	}
+
+	return $r;
+}
+
+/**
+ * Comment history events:
+ * Use comment-related hooks call to _wp_update_comment_history in order to log the comment event.
+ * Add additional actions here, along with corresponding support in _wp_update_comment_history to log in the comment history
+ */
+add_action( 'edit_comment', '_wp_update_comment_history', 10 );
+add_action( 'trashed_comment', '_wp_update_comment_history', 10 );
+add_action( 'untrashed_comment', '_wp_update_comment_history', 10 );
+add_action( 'comment_unapproved_to_approved', '_wp_update_comment_history', 10 );
+add_action( 'comment_approved_to_unapproved', '_wp_update_comment_history', 10 );
+add_action( 'spammed_comment', '_wp_update_comment_history', 10 );
+add_action( 'unspammed_comment', '_wp_update_comment_history', 10 );
+
+
+/**
+ * Get the comment history for a given comment id, as an array.
+ * Allows filtering of the history array for custom reordering or editing of history
+ *
+ * @param int $comment_id Comment ID
+ * @return array Associative array of a comment's history. Keys are time, message, event, and user.
+ */
+function get_comment_history( $comment_id ) {
+	$history = get_comment_meta( $comment_id, '_wp_history', false );
+	return apply_filters('get_comment_history', $history, $comment_id );
+}
+
+
+/**
+ * Sort the comment history in reverse chronological order.
+ *
+ * @uses _sort_comment_history_reverse_chronological() to sort the history entries in reverse chronological order
+ * @param Array $history array of history entries
+ * @return Array sorted array of history events
+ */
+function sort_comment_history( $history ){
+	usort( $history, '_sort_comment_history_reverse_chronological' );
+	return $history;
+}
+add_filter( 'get_comment_history', 'sort_comment_history', 1, 1 );
+
+/**
+ * Used with usort() to sort comment history entries in reverse chronological order
+ *
+ * @access private
+ *
+ * @param  array $a History entry for a comment
+ * @param  array $b Another history entry for the same comment
+ * @return int    -1 if history entry a is older than history entry b, 1 otherwise
+ */
+function _sort_comment_history_reverse_chronological( $a, $b ) {
+	return $a['time'] > $b['time'] ? -1 : 1;
+}
+
+
+/**
+ * Adds the comment history meta box to comment pages in the admin interface
+ * @return void
+ */
+function add_comment_history_meta_box(){
+	add_meta_box( 'comment-history', __('Comment History'), 'comment_history_meta_box_html', 'comment', 'normal' );
+}
+
+function comment_history_meta_box_html( $comment ) {
+	$history = get_comment_history( $comment->comment_ID );
+
+	echo '<div class="comment-history" style="margin: 13px;">';
+
+	if ( $history ) {
+
+		foreach ( $history as $row ) {
+			$time		= date( 'D d M Y @ h:i:m a', (int) $row['time'] ) . ' GMT';
+			$human_time = sprintf( __('%s ago'), human_time_diff( $row['time'] ) );
+			$message	= esc_html( $row['message'] );
+
+			printf( '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="%1$s" title="%1$s">%2$s</span> - %3$s</div>',
+					$time,
+					$human_time,
+					$message
+					);
+		}
+
+	} else {
+
+		echo '<em>'. __('There is no history for this comment.') . '</em>';
+
+	}
+
+	echo '</div> <!-- .comment-history -->';
+
+}
+add_action( 'admin_init', 'add_comment_history_meta_box' );
