Post ID filter for edit-comments

git-svn-id: http://svn.automattic.com/wordpress/trunk@9023 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-09-28 17:48:55 +00:00
parent f5f8f81f8f
commit 5cdac6c1a2
2 changed files with 11 additions and 3 deletions

View File

@ -65,6 +65,8 @@ $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribut
$comment_status = isset($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : '';
$post_id = isset($_GET['p']) ? (int) $_GET['p'] : 0;
$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
$search = attribute_escape( $search_dirty ); ?>
@ -151,7 +153,7 @@ else
$start = $offset = ( $page - 1 ) * $comments_per_page;
list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5 ); // Grab a few extra
list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id ); // Grab a few extra
$comments = array_slice($_comments, 0, $comments_per_page);
$extra_comments = array_slice($_comments, $comments_per_page);

View File

@ -1529,11 +1529,12 @@ function user_row( $user_object, $style = '', $role = '' ) {
return $r;
}
function _wp_get_comment_list( $status = '', $s = false, $start, $num ) {
function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0 ) {
global $wpdb;
$start = abs( (int) $start );
$num = (int) $num;
$post = (int) $post;
if ( 'moderated' == $status )
$approved = "comment_approved = '0'";
@ -1544,6 +1545,11 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num ) {
else
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
if ( $post )
$post = " AND comment_post_ID = '$post'";
else
$post = '';
if ( $s ) {
$s = $wpdb->escape($s);
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
@ -1555,7 +1561,7 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num ) {
$approved
ORDER BY comment_date_gmt DESC LIMIT $start, $num");
} else {
$comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved ORDER BY comment_date_gmt DESC LIMIT $start, $num" );
$comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post ORDER BY comment_date_gmt DESC LIMIT $start, $num" );
}
update_comment_cache($comments);