2003-10-27 08:09:25 +01:00
< ? php
2004-10-19 05:03:06 +02:00
require_once ( 'admin.php' );
2004-04-23 05:23:05 +02:00
$title = __ ( 'Edit Comments' );
2003-12-08 04:46:42 +01:00
$parent_file = 'edit.php' ;
2006-01-10 06:16:17 +01:00
$list_js = true ;
2004-08-23 01:24:50 +02:00
2003-12-11 01:22:36 +01:00
require_once ( 'admin-header.php' );
2004-02-17 09:35:04 +01:00
if ( empty ( $_GET [ 'mode' ])) $mode = 'view' ;
2004-12-12 21:41:19 +01:00
else $mode = wp_specialchars ( $_GET [ 'mode' ], 1 );
2003-10-27 08:09:25 +01:00
?>
2004-08-23 01:24:50 +02:00
2004-02-17 09:35:04 +01:00
< script type = " text/javascript " >
<!--
function checkAll ( form )
{
for ( i = 0 , n = form . elements . length ; i < n ; i ++ ) {
if ( form . elements [ i ] . type == " checkbox " ) {
if ( form . elements [ i ] . checked == true )
form . elements [ i ] . checked = false ;
else
form . elements [ i ] . checked = true ;
}
}
}
//-->
</ script >
2003-10-27 08:09:25 +01:00
< div class = " wrap " >
2004-10-05 09:13:51 +02:00
< h2 >< ? php _e ( 'Comments' ); ?> </h2>
2004-02-13 16:36:28 +01:00
< form name = " searchform " action = " " method = " get " >
< fieldset >
2004-04-23 05:23:05 +02:00
< legend >< ? php _e ( 'Show Comments That Contain...' ) ?> </legend>
2004-12-12 21:41:19 +01:00
< input type = " text " name = " s " value = " <?php if (isset( $_GET['s'] )) echo wp_specialchars( $_GET['s'] , 1); ?> " size = " 17 " />
2004-04-23 05:23:05 +02:00
< input type = " submit " name = " submit " value = " <?php _e('Search') ?> " />
2004-02-17 09:35:04 +01:00
< input type = " hidden " name = " mode " value = " <?php echo $mode ; ?> " />
2004-06-13 18:14:58 +02:00
< ? php _e ( '(Searches within comment text, e-mail, URI, and IP address.)' ) ?>
2004-02-13 16:36:28 +01:00
</ fieldset >
</ form >
2004-04-23 05:23:05 +02:00
< p >< a href = " ?mode=view " >< ? php _e ( 'View Mode' ) ?> </a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
2003-10-27 08:09:25 +01:00
< ? php
2004-07-08 03:10:50 +02:00
if ( ! empty ( $_POST [ 'delete_comments' ] ) ) :
$i = 0 ;
2004-09-18 07:56:28 +02:00
foreach ( $_POST [ 'delete_comments' ] as $comment ) : // Check the permissions on each
2004-07-08 03:10:50 +02:00
$comment = ( int ) $comment ;
2004-05-24 10:22:18 +02:00
$post_id = $wpdb -> get_var ( " SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment " );
2006-02-14 21:09:13 +01:00
// $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 ( ! empty ( $_POST [ 'spam_button' ] ) )
wp_set_comment_status ( $comment , 'spam' );
else
wp_set_comment_status ( $comment , 'delete' );
2004-02-17 11:50:33 +01:00
++ $i ;
2006-02-14 21:09:13 +01:00
}
2004-07-08 03:10:50 +02:00
endforeach ;
2006-02-14 21:09:13 +01:00
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>' ;
if ( ! empty ( $_POST [ 'spam_button' ] ) )
printf ( __ ( '%s comments marked as spam.' ), $i );
else
printf ( __ ( '%s comments deleted.' ), $i );
echo '</p></div>' ;
2004-07-08 03:10:50 +02:00
endif ;
2004-02-17 11:50:33 +01:00
2004-05-09 07:47:02 +02:00
if ( isset ( $_GET [ 's' ])) {
$s = $wpdb -> escape ( $_GET [ 's' ]);
2004-05-24 10:22:18 +02:00
$comments = $wpdb -> get_results ( " SELECT * FROM $wpdb->comments WHERE
2005-01-18 00:32:20 +01:00
( comment_author LIKE '%$s%' OR
2004-02-13 16:36:28 +01:00
comment_author_email LIKE '%$s%' OR
comment_author_url LIKE ( '%$s%' ) OR
comment_author_IP LIKE ( '%$s%' ) OR
2005-01-18 00:32:20 +01:00
comment_content LIKE ( '%$s%' ) ) AND
comment_approved != 'spam'
2004-02-17 09:35:04 +01:00
ORDER BY comment_date DESC " );
2004-02-13 16:36:28 +01:00
} else {
2004-10-05 09:25:21 +02:00
if ( isset ( $_GET [ 'offset' ]) )
$offset = ( int ) $_GET [ 'offset' ] * 20 ;
else
$offset = 0 ;
2005-01-10 21:21:06 +01:00
$comments = $wpdb -> get_results ( " SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset ,20 " );
2003-10-27 08:09:25 +01:00
}
2004-02-17 09:35:04 +01:00
if ( 'view' == $mode ) {
2003-10-27 08:09:25 +01:00
if ( $comments ) {
2004-10-05 09:25:21 +02:00
if ( $offset )
$start = " start=' $offset ' " ;
else
$start = '' ;
2005-08-31 04:39:17 +02:00
echo " <ol id='the-list' class='commentlist' $start > " ;
2004-10-05 09:13:51 +02:00
$i = 0 ;
2003-10-27 08:09:25 +01:00
foreach ( $comments as $comment ) {
2004-10-05 09:13:51 +02:00
++ $i ; $class = '' ;
2004-05-24 10:22:18 +02:00
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID " ));
2003-11-12 16:22:47 +01:00
$comment_status = wp_get_comment_status ( $comment -> comment_ID );
2004-10-05 09:13:51 +02:00
if ( 'unapproved' == $comment_status )
$class .= ' unapproved' ;
if ( $i % 2 )
$class .= ' alternate' ;
2005-08-31 04:39:17 +02:00
echo " <li id='comment- $comment->comment_ID ' class=' $class '> " ;
2006-02-12 08:53:23 +01:00
?>
2005-08-07 10:58:10 +02:00
< p >< strong >< ? php _e ( 'Name:' ) ?> </strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
2006-02-12 08:53:23 +01:00
2003-10-27 08:40:15 +01:00
< ? php comment_text () ?>
2004-04-23 05:23:05 +02:00
2004-11-23 16:09:24 +01:00
< p >< ? php _e ( 'Posted' ); echo ' ' ; comment_date ( 'M j, g:i A' );
2005-07-17 23:21:50 +02:00
if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) {
2006-02-21 07:11:46 +01:00
echo " | <a href= \" comment.php?action=editcomment&comment= " . $comment -> comment_ID . " \" > " . __ ( 'Edit Comment' ) . " </a> " ;
echo " | <a href= \" comment.php?action=deletecomment&p= " . $comment -> comment_post_ID . " &comment= " . $comment -> comment_ID . " \" onclick= \" return deleteSomething( 'comment', $comment->comment_ID , ' " . sprintf ( __ ( " You are about to delete this comment by "%s". \\ n"Cancel" to stop, "OK" to delete. " ), wp_specialchars ( $comment -> comment_author , 1 )) . " ' ); \" > " . __ ( 'Delete Comment' ) . " </a> " ;
echo " | <a href= \" comment.php?action=deletecomment&delete_type=spam&p= " . $comment -> comment_post_ID . " &comment= " . $comment -> comment_ID . " \" onclick= \" return deleteSomething( 'comment-as-spam', $comment->comment_ID , ' " . sprintf ( __ ( " You are about to mark as spam this comment by "%s". \\ n"Cancel" to stop, "OK" to mark as spam. " ), wp_specialchars ( $comment -> comment_author , 1 )) . " ' ); \" > " . __ ( 'Mark Comment as Spam' ) . " </a> " ;
2003-10-27 08:09:25 +01:00
} // end if any comments to show
2003-12-08 01:31:02 +01:00
// Get post title
2006-02-21 07:11:46 +01:00
$post = get_post ( $comment -> comment_post_ID );
$post_title = $post -> post_title ;
$post_title = ( '' == $post_title ) ? " # $comment->comment_post_ID " : $post_title ;
if ( 'page' == $post -> post_type ) {
if ( current_user_can ( 'edit_page' , $comment -> comment_post_ID ) ) ?>
| < a href = " page.php?action=edit&post=<?php echo $comment->comment_post_ID ; ?> " >< ? php printf ( __ ( 'Edit Page “%s”' ), $post_title ); ?> </a>
< ? php } else {
if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) ?>
| < a href = " post.php?action=edit&post=<?php echo $comment->comment_post_ID ; ?> " >< ? php printf ( __ ( 'Edit Post “%s”' ), $post_title ); ?> </a>
< ? php } ?>
2004-11-23 16:09:24 +01:00
| < a href = " <?php echo get_permalink( $comment->comment_post_ID ); ?> " >< ? php _e ( 'View Post' ) ?> </a></p>
2003-10-27 08:40:15 +01:00
</ li >
2003-10-27 08:09:25 +01:00
2004-10-05 09:25:21 +02:00
< ? php } // end foreach ?>
</ ol >
2005-08-31 04:39:17 +02:00
< div id = " ajax-response " ></ div >
2004-10-05 09:25:21 +02:00
< ? php
2004-02-17 09:35:04 +01:00
} else {
?>
< p >
2004-05-14 08:19:46 +02:00
< strong >< ? php _e ( 'No comments found.' ) ?> </strong></p>
2006-02-12 08:53:23 +01:00
2004-02-17 09:35:04 +01:00
< ? php
} // end if ($comments)
} elseif ( 'edit' == $mode ) {
2004-02-17 11:50:33 +01:00
2004-02-17 09:35:04 +01:00
if ( $comments ) {
echo ' < form name = " deletecomments " id = " deletecomments " action = " " method = " post " >
< table width = " 100% " cellpadding = " 3 " cellspacing = " 3 " >
< tr >
< th scope = " col " >*</ th >
2004-04-23 05:23:05 +02:00
< th scope = " col " > ' . __(' Name ') . ' </ th >
2004-06-13 18:14:58 +02:00
< th scope = " col " > ' . __(' E - mail ') . ' </ th >
2004-04-23 05:23:05 +02:00
< th scope = " col " > ' . __(' IP ') . ' </ th >
< th scope = " col " > ' . __(' Comment Excerpt ') . ' </ th >
< th scope = " col " colspan = " 3 " > ' . __(' Actions ') . ' </ th >
2004-02-17 09:35:04 +01:00
</ tr > ' ;
foreach ( $comments as $comment ) {
2004-05-24 10:22:18 +02:00
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID " ));
2004-07-06 20:14:42 +02:00
$class = ( 'alternate' == $class ) ? '' : 'alternate' ;
2004-02-17 09:35:04 +01:00
?>
2004-07-06 20:14:42 +02:00
< tr class = '<?php echo $class; ?>' >
2005-07-17 23:21:50 +02:00
< td >< ? php if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) { ?> <input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
2004-04-19 10:09:27 +02:00
< td >< ? php comment_author_link () ?> </td>
2004-02-17 09:35:04 +01:00
< td >< ? php comment_author_email_link () ?> </td>
< td >< a href = " http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?> " >< ? php comment_author_IP () ?> </a></td>
< td >< ? php comment_excerpt (); ?> </td>
2004-04-23 05:23:05 +02:00
< td >< a href = " <?php echo get_permalink( $comment->comment_post_ID ); ?>#comment-<?php comment_ID() ?> " class = " edit " >< ? php _e ( 'View' ) ?> </a></td>
2005-07-17 23:21:50 +02:00
< td >< ? php if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) {
2006-02-21 07:11:46 +01:00
echo " <a href='comment.php?action=editcomment&comment= $comment->comment_ID ' class='edit'> " . __ ( 'Edit' ) . " </a> " ; } ?> </td>
2005-07-17 23:21:50 +02:00
< td >< ? php if ( current_user_can ( 'edit_post' , $comment -> comment_post_ID ) ) {
2006-02-21 07:11:46 +01:00
echo " <a href= \" comment.php?action=deletecomment&p= " . $comment -> comment_post_ID . " &comment= " . $comment -> comment_ID . " \" onclick= \" return confirm(' " . sprintf ( __ ( " You are about to delete this comment by \ '%s \ ' \\ n \ 'Cancel \ ' to stop, \ 'OK \ ' to delete. " ), $comment -> comment_author ) . " ') \" class='delete'> " . __ ( 'Delete' ) . " </a> " ; } ?> </td>
2004-02-17 09:35:04 +01:00
</ tr >
< ? php
} // end foreach
?> </table>
2004-04-23 05:23:05 +02:00
< p >< a href = " javascript:; " onclick = " checkAll(document.getElementById('deletecomments')); return false; " >< ? php _e ( 'Invert Checkbox Selection' ) ?> </a></p>
2006-02-17 02:29:33 +01:00
< p class = " submit " >< input type = " submit " name = " delete_button " value = " <?php _e('Delete Checked Comments »') ?> " onclick = " return confirm('<?php _e( " You are about to delete these comments permanently \\n \ 'Cancel\' to stop, \'OK\' to delete.") ?>' ) " />
< input type = " submit " name = " spam_button " value = " <?php _e('Mark Checked Comments as Spam »') ?> " onclick = " return confirm('<?php _e( " You are about to mark these comments as spam \\n \ 'Cancel\' to stop, \'OK\' to mark as spam.") ?>' ) " /></p>
2004-02-17 09:35:04 +01:00
</ form >
< ? php
2003-10-27 08:09:25 +01:00
} else {
2004-02-17 11:50:33 +01:00
?>
< p >
2004-04-23 05:23:05 +02:00
< strong >< ? php _e ( 'No results found.' ) ?> </strong>
2004-02-17 11:50:33 +01:00
</ p >
< ? php
2003-10-27 08:09:25 +01:00
} // end if ($comments)
2004-02-17 09:35:04 +01:00
}
2003-10-27 08:09:25 +01:00
?>
</ div >
2005-08-31 04:39:17 +02:00
< ? php include ( 'admin-footer.php' ); ?>