X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/0f29eadd474473203a1182f52af1aa82721cecbd..4f4e083f6f77639c41e2b1ddb200de8e34301cee:/wp-admin/edit-comments.php
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index ab0f0a8e..7df02103 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -1,175 +1,383 @@
+$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
-
-
-
-
-
|
-get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
+
+ if ( !current_user_can('edit_post', $_post_id) )
+ continue;
- $i = 0;
- foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
- $comment = (int) $comment;
- $post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
- $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
- if ( current_user_can('edit_post', $post_id) ) :
- wp_set_comment_status($comment, "delete");
- ++$i;
- endif;
+ switch( $doaction ) {
+ case 'markspam' :
+ wp_set_comment_status($comment_id, 'spam');
+ $spammed++;
+ break;
+ case 'delete' :
+ wp_set_comment_status($comment_id, 'delete');
+ $deleted++;
+ break;
+ case 'approve' :
+ wp_set_comment_status($comment_id, 'approve');
+ $approved++;
+ break;
+ case 'unapprove' :
+ wp_set_comment_status($comment_id, 'hold');
+ $unapproved++;
+ break;
+ }
endforeach;
- echo "
" . sprintf(__('%s comments deleted.'), $i) . "
";
-endif;
-
-if (isset($_GET['s'])) {
- $s = $wpdb->escape($_GET['s']);
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
- (comment_author LIKE '%$s%' OR
- comment_author_email LIKE '%$s%' OR
- comment_author_url LIKE ('%$s%') OR
- comment_author_IP LIKE ('%$s%') OR
- comment_content LIKE ('%$s%') ) AND
- comment_approved != 'spam'
- ORDER BY comment_date DESC");
-} else {
- if ( isset($_GET['offset']) )
- $offset = (int) $_GET['offset'] * 20;
- else
- $offset = 0;
-
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20");
+
+ $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
+ if ( $post_id )
+ $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
+ if ( isset($_REQUEST['apage']) )
+ $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
+ if ( !empty($_REQUEST['mode']) )
+ $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to);
+ if ( !empty($_REQUEST['comment_status']) )
+ $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to);
+ if ( !empty($_REQUEST['s']) )
+ $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
+ wp_redirect( $redirect_to );
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
+ exit;
}
-if ('view' == $mode) {
- if ($comments) {
- if ($offset)
- $start = " start='$offset'";
- else
- $start = '';
-
- echo "
-
+if ( $post_id )
+ $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
+else
+ $title = __('Edit Comments');
+
+require_once('admin-header.php');
+
+$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']);
+
+$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
+if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam')) )
+ $comment_status = 'all';
+
+$comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
+
+$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
+$search = esc_attr( $search_dirty ); ?>
+
+
+
+
' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_GET['s'] ) ), 50 ) ) . '' ); ?>
+
0 || $deleted > 0 || $spam > 0 ) {
+ echo '
';
+
+ if ( $approved > 0 ) {
+ printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
+ echo '
';
+ }
+
+ if ( $deleted > 0 ) {
+ printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
+ echo '
';
+ }
- ?>
-
-
-
- ';
- wp_nonce_field('bulk-comments');
- echo '
-
-
')" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+