2003-10-27 02:09:25 -05:00
< ? php
2004-04-22 23:23:05 -04:00
require_once ( '../wp-includes/wp-l10n.php' );
$title = __ ( 'Edit Comments' );
2003-12-07 22:46:42 -05:00
$parent_file = 'edit.php' ;
2003-12-10 19:22:36 -05:00
require_once ( 'admin-header.php' );
2004-02-17 03:35:04 -05:00
if ( empty ( $_GET [ 'mode' ])) $mode = 'view' ;
else $mode = $_GET [ 'mode' ];
2003-10-27 02:09:25 -05:00
?>
2003-10-27 02:13:59 -05:00
< ul id = " adminmenu2 " >
2004-04-22 23:23:05 -04:00
< li >< a href = " edit.php " >< ? php _e ( 'Posts' ) ?> </a></li>
< li >< a href = " edit-comments.php " class = " current " >< ? php _e ( 'Comments' ) ?> </a></li>
< li class = " last " >< a href = " moderation.php " >< ? php _e ( 'Awaiting Moderation' ) ?> </a></li>
2003-10-27 02:13:59 -05:00
</ ul >
2004-02-17 03:35:04 -05: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 02:09:25 -05:00
< div class = " wrap " >
2004-02-13 10:36:28 -05:00
< form name = " searchform " action = " " method = " get " >
< fieldset >
2004-04-22 23:23:05 -04:00
< legend >< ? php _e ( 'Show Comments That Contain...' ) ?> </legend>
2004-02-13 10:36:28 -05:00
< input type = " text " name = " s " value = " <?php echo $s ; ?> " size = " 17 " />
2004-04-22 23:23:05 -04:00
< input type = " submit " name = " submit " value = " <?php _e('Search') ?> " />
2004-02-17 03:35:04 -05:00
< input type = " hidden " name = " mode " value = " <?php echo $mode ; ?> " />
2004-04-22 23:23:05 -04:00
< ? php _e ( '(Searches within comment text, email, URI, and IP address.)' ) ?>
2004-02-13 10:36:28 -05:00
</ fieldset >
</ form >
2004-04-22 23:23:05 -04: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 02:09:25 -05:00
< ? php
2004-02-17 05:50:33 -05:00
if ( ! empty ( $delete_comments )) {
// I had this all as one query but then realized we weren't checking permissions on each comment.
$del_comments = '' ; $safe_delete_commeents = '' ; $i = 0 ;
foreach ( $delete_comments as $comment ) { // Check the permissions on each
$comment = intval ( $comment );
$post_id = $wpdb -> get_var ( " SELECT comment_post_ID FROM $tablecomments WHERE comment_ID = $comment " );
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $tableposts WHERE ID = $post_id " ));
if (( $user_level > $authordata -> user_level ) or ( $user_login == $authordata -> user_login )) {
$wpdb -> query ( " DELETE FROM $tablecomments WHERE comment_ID = $comment " );
++ $i ;
}
}
2004-04-22 23:23:05 -04:00
echo " <div class='wrap'><p> " . sprintf ( __ ( '%s comments deleted.' ), $i ) . " </p></div> " ;
2004-02-17 05:50:33 -05:00
}
2004-02-13 10:36:28 -05:00
if ( $s ) {
$s = $wpdb -> escape ( $s );
$comments = $wpdb -> get_results ( " SELECT * FROM $tablecomments 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%' )
2004-02-17 03:35:04 -05:00
ORDER BY comment_date DESC " );
2004-02-13 10:36:28 -05:00
} else {
2004-02-17 03:35:04 -05:00
$comments = $wpdb -> get_results ( " SELECT * FROM $tablecomments ORDER BY comment_date DESC LIMIT 20 " );
2003-10-27 02:09:25 -05:00
}
2004-02-17 03:35:04 -05:00
if ( 'view' == $mode ) {
2003-10-27 02:09:25 -05:00
if ( $comments ) {
2003-10-27 02:40:15 -05:00
echo '<ol>' ;
2003-10-27 02:09:25 -05:00
foreach ( $comments as $comment ) {
2004-02-17 05:50:33 -05:00
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID " ));
2003-11-12 10:22:47 -05:00
$comment_status = wp_get_comment_status ( $comment -> comment_ID );
2003-11-30 17:13:53 -05:00
if ( 'unapproved' == $comment_status ) {
echo '<li class="unapproved" style="border-bottom: 1px solid #ccc;">' ;
} else {
echo '<li style="border-bottom: 1px solid #ccc;">' ;
2003-11-12 10:22:47 -05:00
}
2003-11-30 17:13:53 -05:00
?>
2004-04-22 23:23:05 -04:00
< p >< strong >< ? php _e ( 'Name:' ) ?> </strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('Email:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_email) { ?> | <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>
2003-10-27 02:40:15 -05:00
< ? php comment_text () ?>
2004-04-22 23:23:05 -04:00
< p >< ? php _e ( 'Posted' ); echo ' ' ; comment_date ( 'M j, g:i A' ); ?> | <?php
2003-10-27 02:09:25 -05:00
if (( $user_level > $authordata -> user_level ) or ( $user_login == $authordata -> user_login )) {
2004-04-22 23:23:05 -04:00
echo " <a href= \" post.php?action=editcomment&comment= " . $comment -> comment_ID . " \" > " . __ ( 'Edit Comment' ) . " </a> " ;
echo " | <a href= \" post.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 ) . " ') \" > " . __ ( 'Delete Comment' ) . " </a> — " ;
2003-10-27 02:09:25 -05:00
} // end if any comments to show
2003-12-07 19:31:02 -05:00
// Get post title
$post_title = $wpdb -> get_var ( " SELECT post_title FROM $tableposts WHERE ID = $comment->comment_post_ID " );
$post_title = ( '' == $post_title ) ? " # $comment->comment_post_ID " : $post_title ;
2004-04-22 23:23:05 -04:00
?> <a href="post.php?action=edit&post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post “%s”'), stripslashes($post_title)); ?></a> | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
2003-10-27 02:40:15 -05:00
</ li >
2003-10-27 02:09:25 -05:00
< ? php
} // end foreach
2003-10-27 02:40:15 -05:00
echo '</ol>' ;
2004-02-17 03:35:04 -05:00
} else {
?>
< p >
2004-04-22 23:23:05 -04:00
< strong >< ? php _e ( 'No results found.' ) ?> </strong></p>
2004-02-17 03:35:04 -05:00
< ? php
} // end if ($comments)
} elseif ( 'edit' == $mode ) {
2004-02-17 05:50:33 -05:00
2004-02-17 03:35:04 -05: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-22 23:23:05 -04:00
< th scope = " col " > ' . __(' Name ') . ' </ th >
< th scope = " col " > ' . __(' Email ') . ' </ th >
< th scope = " col " > ' . __(' IP ') . ' </ th >
< th scope = " col " > ' . __(' Comment Excerpt ') . ' </ th >
< th scope = " col " colspan = " 3 " > ' . __(' Actions ') . ' </ th >
2004-02-17 03:35:04 -05:00
</ tr > ' ;
foreach ( $comments as $comment ) {
2004-02-17 05:50:33 -05:00
$authordata = get_userdata ( $wpdb -> get_var ( " SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID " ));
2004-02-17 03:35:04 -05:00
$bgcolor = ( '#eee' == $bgcolor ) ? 'none' : '#eee' ;
?>
< tr style = 'background-color: <?php echo $bgcolor; ?>' >
2004-02-17 05:50:33 -05:00
< td >< ? php if (( $user_level > $authordata -> user_level ) or ( $user_login == $authordata -> user_login )) { ?> <input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
2004-04-19 04:09:27 -04:00
< td >< ? php comment_author_link () ?> </td>
2004-02-17 03:35:04 -05: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-22 23:23:05 -04:00
< td >< a href = " <?php echo get_permalink( $comment->comment_post_ID ); ?>#comment-<?php comment_ID() ?> " class = " edit " >< ? php _e ( 'View' ) ?> </a></td>
2004-02-17 03:35:04 -05:00
< td >< ? php if (( $user_level > $authordata -> user_level ) or ( $user_login == $authordata -> user_login )) {
2004-04-22 23:23:05 -04:00
echo " <a href='post.php?action=editcomment&comment= $comment->comment_ID ' class='edit'> " . __ ( 'Edit' ) . " </a> " ; } ?> </td>
2004-02-17 03:35:04 -05:00
< td >< ? php if (( $user_level > $authordata -> user_level ) or ( $user_login == $authordata -> user_login )) {
2004-04-22 23:23:05 -04:00
echo " <a href= \" post.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 03:35:04 -05:00
</ tr >
< ? php
} // end foreach
?> </table>
2004-04-22 23:23:05 -04:00
< p >< a href = " javascript:; " onclick = " checkAll(document.getElementById('deletecomments')); return false; " >< ? php _e ( 'Invert Checkbox Selection' ) ?> </a></p>
< p style = " text-align: right; " >< input type = " submit " name = " Submit " 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.") ?>' ) " /> </p>
2004-02-17 03:35:04 -05:00
</ form >
< ? php
2003-10-27 02:09:25 -05:00
} else {
2004-02-17 05:50:33 -05:00
?>
< p >
2004-04-22 23:23:05 -04:00
< strong >< ? php _e ( 'No results found.' ) ?> </strong>
2004-02-17 05:50:33 -05:00
</ p >
< ? php
2003-10-27 02:09:25 -05:00
} // end if ($comments)
2004-02-17 03:35:04 -05:00
}
2003-10-27 02:09:25 -05:00
?>
</ div >
< ? php
2003-12-10 19:22:36 -05:00
include ( 'admin-footer.php' );
2003-11-12 10:22:47 -05:00
?>