From 761816fa7648b58220272e205bee33106b11f7aa Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 23 Feb 2008 08:01:51 +0000 Subject: [PATCH] Manage comments rework. WIP. git-svn-id: https://develop.svn.wordpress.org/trunk@6993 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-comments.php | 199 +++++++++++++++++---------------- wp-admin/includes/template.php | 15 ++- 2 files changed, 117 insertions(+), 97 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index fa5e8b1013..4566e30c3b 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -6,23 +6,6 @@ $parent_file = 'edit-comments.php'; wp_enqueue_script( 'admin-comments' ); wp_enqueue_script('admin-forms'); -require_once('admin-header.php'); -if (empty($_GET['mode'])) $mode = 'view'; -else $mode = attribute_escape($_GET['mode']); -?> -
-

-
-
- - - - - -
-
-

|

-

'; if ( !empty( $_POST['spam_button'] ) ) { printf(__ngettext('%s comment marked as spam.', '%s comments marked as spam.', $i), $i); @@ -46,8 +30,54 @@ if ( !empty( $_POST['delete_comments'] ) ) : printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i); } echo '

'; + */ + // TODO redirect with message endif; +require_once('admin-header.php'); +if (empty($_GET['mode'])) $mode = 'view'; +else $mode = attribute_escape($_GET['mode']); +?> + +
+
+

+ +
    + __('Awaiting Moderation'), 'approved' => __('Approved')); +foreach ( $stati as $status => $label ) { + $class = ''; + + if ( $status == $comment_status ) + $class = ' class="current"'; + + $status_links[] = "
  • " . $label . ''; +} +$class = ( '' === $comment_status ) ? ' class="current"' : ''; +$status_links[] = "
  • ".__('All Comments').""; +echo implode(' |
  • ', $status_links) . ''; +unset($status_links); +?> +
+ +

+ + +

+ + + +

|

+ + $page )); -if ( $page_links ) - echo ""; - -if ('view' == $mode) { - if ($comments) { - $offset = $offset + 1; - $start = " start='$offset'"; - - echo "
    \n"; - $i = 0; - foreach ( $comments as $comment ) { - _wp_comment_list_item( $comment->comment_ID, ++$i ); - } - echo "
\n\n"; - -if ( $extra_comments ) : ?> -
- -
+
+ +
$page_links
"; +?> - ?> -

-

+
+ + + + +
- +
- if ($comments) { - echo '
'; - wp_nonce_field('bulk-comments'); - echo ' +
+ +
- - - - - - + + + + -'; - foreach ($comments as $comment) { + +comment_post_ID); $authordata = get_userdata($post->post_author); $comment_status = wp_get_comment_status($comment->comment_ID); $class = ('alternate' == $class) ? '' : 'alternate'; $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; + $post_link = '' . get_the_title($comment->comment_post_ID) . ''; + $author_url = get_comment_author_url(); + if ( 'http://' == $author_url ) + $author_url = ''; ?> - - - - - - + - - + + } + ?> +
' . __('Name') . '' . __('E-mail') . '' . __('IP') . '' . __('Comment Excerpt') . '' . __('Actions') . '
comment_post_ID) ) { ?> - - - + comment_post_ID) ) { ?> +
+ + | + + comment_author_email) ): ?> + | + + +

+
comment_post_ID) ) { - echo "" . __('Edit') . ""; } ?>comment_post_ID) ) { + + comment_post_ID) ) { + echo "" . __('Edit') . " | "; $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); echo "" . __('Delete') . " "; - } ?>
-

'); return false } return confirm('')" /> - '); return false } return confirm('')" />

-
+

$page_links

"; - ?> - +
+$page_links
"; +?> +
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 106c4de16f..e00ca0f867 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -567,12 +567,21 @@ function user_row( $user_object, $style = '', $role = '' ) { return $r; } -function _wp_get_comment_list( $s = false, $start, $num ) { +function _wp_get_comment_list( $status = '', $s = false, $start, $num ) { global $wpdb; $start = abs( (int) $start ); $num = (int) $num; + if ( 'moderated' == $status ) + $approved = "comment_approved = '0'"; + elseif ( 'approved' == $status ) + $approved = "comment_approved = '1'"; + elseif ( 'spam' == $status ) + $approved = "comment_approved = 'spam'"; + else + $approved = "comment_approved != 'spam'"; + if ( $s ) { $s = $wpdb->escape($s); $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE @@ -581,10 +590,10 @@ function _wp_get_comment_list( $s = false, $start, $num ) { comment_author_url LIKE ('%$s%') OR comment_author_IP LIKE ('%$s%') OR comment_content LIKE ('%$s%') ) AND - comment_approved != 'spam' + $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num"); } else { - $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments USE INDEX (comment_date_gmt) WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); + $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments USE INDEX (comment_date_gmt) WHERE $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num" ); } update_comment_cache($comments);