X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/177fd6fefd2e3d5a0ea6591c71d660cabdb3c1a4..refs/tags/wordpress-2.9:/wp-admin/edit-comments.php diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index bc62681b..ee23b3e3 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -1,36 +1,103 @@ 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) ) + if ( (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp']) ) { + $comment_status = $wpdb->escape($_REQUEST['comment_status']); + $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']); + $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" ); + $doaction = 'delete'; + } elseif ( ($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments']) ) { + $comment_ids = $_REQUEST['delete_comments']; + $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; + } elseif ( $_REQUEST['doaction'] == 'undo' && isset($_REQUEST['ids']) ) { + $comment_ids = array_map( 'absint', explode(',', $_REQUEST['ids']) ); + $doaction = $_REQUEST['action']; + } else { + wp_redirect($_SERVER['HTTP_REFERER']); + } + + $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0; + + foreach ($comment_ids as $comment_id) { // Check the permissions on each + $_post_id = (int) $wpdb->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; - if ( !empty( $_REQUEST['spamit'] ) ) { - wp_set_comment_status($comment, 'spam'); - $comments_spammed++; - } elseif ( !empty( $_REQUEST['deleteit'] ) ) { - wp_set_comment_status($comment, 'delete'); - $comments_deleted++; - } elseif ( !empty( $_REQUEST['approveit'] ) ) { - wp_set_comment_status($comment, 'approve'); - $comments_approved++; - } elseif ( !empty( $_REQUEST['unapproveit'] ) ) { - wp_set_comment_status($comment, 'hold'); - $comments_unapproved++; + + switch( $doaction ) { + case 'approve' : + wp_set_comment_status($comment_id, 'approve'); + $approved++; + break; + case 'unapprove' : + wp_set_comment_status($comment_id, 'hold'); + $unapproved++; + break; + case 'spam' : + wp_spam_comment($comment_id); + $spammed++; + break; + case 'unspam' : + wp_unspam_comment($comment_id); + $unspammed++; + break; + case 'trash' : + wp_trash_comment($comment_id); + $trashed++; + break; + case 'untrash' : + wp_untrash_comment($comment_id); + $untrashed++; + break; + case 'delete' : + wp_delete_comment($comment_id); + $deleted++; + break; } - endforeach; - $redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved; + } + + $redirect_to = 'edit-comments.php'; + + if ( $approved ) + $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); + if ( $unapproved ) + $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); + if ( $spammed ) + $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); + if ( $unspammed ) + $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); + if ( $trashed ) + $redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to ); + if ( $untrashed ) + $redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to ); + if ( $deleted ) + $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); + if ( $trashed || $spammed ) + $redirect_to = add_query_arg( 'ids', join(',', $comment_ids), $redirect_to ); + + 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']) ) @@ -38,50 +105,72 @@ if ( !empty( $_REQUEST['delete_comments'] ) ) { if ( !empty($_REQUEST['s']) ) $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to); wp_redirect( $redirect_to ); -} elseif ( !empty($_GET['_wp_http_referer']) ) { - wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); +} 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 ( $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'); -if ( empty($_GET['mode']) ) - $mode = 'detail'; -else - $mode = attribute_escape($_GET['mode']); +$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); -if ( isset($_GET['comment_status']) ) - $comment_status = attribute_escape($_GET['comment_status']); -else - $comment_status = ''; +$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; +if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) ) + $comment_status = 'all'; -if ( isset($_GET['s']) ) - $search_dirty = $_GET['s']; -else - $search_dirty = ''; -$search = attribute_escape( $search_dirty ); -?> - + +
';
if ( $approved > 0 ) {
- printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved );
+ printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
echo '
';
}
-
- if ( $deleted > 0 ) {
- printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
+ 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 ' ' . __('Undo') . '
';
+ }
+ if ( $unspammed > 0 ) {
+ printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
echo '
';
}
-
- if ( $spam > 0 ) {
- printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
+ 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 ' ' . __('Undo') . '
';
+ }
+ if ( $untrashed > 0 ) {
+ printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed );
+ echo '
';
+ }
+ if ( $deleted > 0 ) {
+ printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
echo '
';
}
@@ -89,109 +178,201 @@ if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['sp
}
}
?>
-