From 7ed7543a6d158990ff265cb219e3028ebdfdb9bc Mon Sep 17 00:00:00 2001 From: Dougal Campbell Date: Tue, 23 Nov 2004 15:09:24 +0000 Subject: [PATCH] Use new user_can_foo() functions, clean up comment editing git-svn-id: https://develop.svn.wordpress.org/trunk@1875 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-comments.php | 25 +++++++++++++++---------- wp-includes/functions-post.php | 3 ++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 21aed3465c..5d68fa6c07 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -43,7 +43,7 @@ if ( !empty( $_POST['delete_comments'] ) ) : $comment = (int) $comment; $post_id = $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 ( ($user_level > $authordata->user_level) || ($user_login == $authordata->user_login) ) : + if ( user_can_delete_post_comments($user_ID, $post_id) ) : $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $comment"); ++$i; endif; @@ -91,15 +91,20 @@ if ('view' == $mode) { -

| $authordata->user_level) or ($user_login == $authordata->user_login)) { - echo "comment_ID."\">" . __('Edit Comment') . ""; +

comment_post_ID) ) { + echo " | comment_ID."\">" . __('Edit Comment') . ""; + } + if ( user_can_delete_post_comments($user_ID, $comment->comment_post_ID) ) { echo " | 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') . " — "; } // end if any comments to show // Get post title - $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"); - $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; - ?> |

+ if ( user_can_edit_post($user_ID, $comment->comment_post_ID) ) { + $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"); + $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; + ?> + + |

@@ -138,15 +143,15 @@ if ('view' == $mode) { $class = ('alternate' == $class) ? '' : 'alternate'; ?> - $authordata->user_level) or ($user_login == $authordata->user_login)) { ?> + comment_post_ID) ) { ?> - $authordata->user_level) or ($user_login == $authordata->user_login)) { + comment_post_ID) ) { echo "" . __('Edit') . ""; } ?> - $authordata->user_level) or ($user_login == $authordata->user_login)) { + comment_post_ID) ) { echo "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') . ""; } ?> ID) - || ($author_data->user_level > $post_author_data->user_level) ) { + || ($author_data->user_level > $post_author_data->user_level) + || ($author_data->user_level >= 10) ) { return true; } else { return false;