Ticket #11441: 11441-comment-ays.diff
File 11441-comment-ays.diff, 11.3 KB (added by , 15 years ago) |
---|
-
comment.php
35 35 * @param string $msg Error Message. Assumed to contain HTML and be sanitized. 36 36 */ 37 37 function comment_footer_die( $msg ) { 38 global $hook_suffix; 38 39 echo "<div class='wrap'><p>$msg</p></div>"; 39 40 include('admin-footer.php'); 40 41 die; … … 70 71 case 'trash' : 71 72 case 'spam' : 72 73 74 $comment_id = absint( $_GET['c'] ); 75 76 if ( !$comment = get_comment_to_edit( $comment_id ) ) { 77 wp_redirect( admin_url('edit-comments.php?error=id') ); 78 die(); 79 } 80 81 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) { 82 wp_redirect( admin_url('edit-comments.php?error=cap') ); 83 die(); 84 } 85 86 if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) { 87 wp_redirect( admin_url("edit-comments.php?same=$comment_id&p=" . absint( $comment->comment_post_ID ) ) ); 88 die(); 89 } 90 73 91 require_once('admin-header.php'); 74 75 $comment_id = absint( $_GET['c'] );76 92 $formaction = $action . 'comment'; 77 93 $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; 78 94 $nonce_action .= $comment_id; 79 95 80 if ( !$comment = get_comment_to_edit( $comment_id ) )81 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );82 83 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )84 comment_footer_die( 'approve' != $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );85 96 ?> 86 97 <div class='wrap'> 87 98 88 99 <div class="narrow"> 100 101 <?php screen_icon(); ?> 102 <h2><?php _e( 'Moderate Comment' ); ?></h2> 103 89 104 <?php 90 105 switch ( $action ) { 91 106 case 'spam' : … … 105 120 $button = __('Approve Comment'); 106 121 break; 107 122 } 123 124 if ( $comment->comment_approved != '0' ) { // if not unapproved 125 switch ( $comment->comment_approved ) { 126 case '1': 127 $message = __('This comment is currently approved.'); 128 break; 129 case 'spam': 130 $message = __('This comment is currently marked as spam.'); 131 break; 132 case 'trash': 133 $message = __('This comment is currently in the Trash.'); 134 break; 135 } 108 136 ?> 109 137 138 <div class="updated"> 139 <p><?php echo $message; ?></p> 140 </div> 141 <?php 142 } 143 ?> 144 110 145 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> 111 146 112 147 <table class="form-table comment-ays"> … … 155 190 <?php 156 191 break; 157 192 158 case 'deletecomment' : 159 case 'trashcomment' : 160 case 'untrashcomment' : 161 case 'spamcomment' : 162 case 'unspamcomment' : 193 case 'deletecomment' : 194 case 'trashcomment' : 195 case 'untrashcomment' : 196 case 'spamcomment' : 197 case 'unspamcomment' : 198 case 'approvecomment' : 199 case 'unapprovecomment' : 200 163 201 $comment_id = absint( $_REQUEST['c'] ); 164 check_admin_referer( 'delete-comment_' . $comment_id ); 202 if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) 203 check_admin_referer( 'approve-comment_' . $comment_id ); 204 else 205 check_admin_referer( 'delete-comment_' . $comment_id ); 165 206 166 207 $noredir = isset($_REQUEST['noredir']); 167 208 … … 170 211 if ( !current_user_can('edit_post', $comment->comment_post_ID ) ) 171 212 comment_footer_die( __('You are not allowed to edit comments on this post.') ); 172 213 173 if ( '' != wp_get_referer() && false == $noredir && false === strpos( wp_get_referer(), 'comment.php') )214 if ( '' != wp_get_referer() && false == $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) 174 215 $redir = wp_get_referer(); 175 216 elseif ( '' != wp_get_original_referer() && false == $noredir ) 176 217 $redir = wp_get_original_referer(); 177 218 else 178 $redir = admin_url('edit-comments.php ');219 $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); 179 220 180 221 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir ); 181 222 … … 199 240 case 'unspamcomment' : 200 241 wp_unspam_comment($comment_id); 201 242 $redir = add_query_arg( array('unspammed' => '1'), $redir ); 202 break; 243 break; 244 case 'approvecomment' : 245 wp_set_comment_status( $comment_id, 'approve' ); 246 $redir = add_query_arg( array( 'approved' => 1 ), $redir ); 247 break; 248 case 'unapprovecomment' : 249 wp_set_comment_status( $comment_id, 'hold' ); 250 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); 203 251 } 204 252 205 253 wp_redirect( $redir ); … … 207 255 die; 208 256 break; 209 257 210 case 'approvecomment' :211 case 'unapprovecomment' :212 $comment_id = absint( $_GET['c'] );213 check_admin_referer( 'approve-comment_' . $comment_id );214 215 $noredir = isset( $_GET['noredir'] );216 217 if ( !$comment = get_comment( $comment_id ) )218 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );219 220 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) {221 if ( 'approvecomment' == $action )222 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );223 else224 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );225 }226 227 if ( '' != wp_get_referer() && false == $noredir )228 $redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() );229 else230 $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );231 232 if ( 'approvecomment' == $action ) {233 wp_set_comment_status( $comment_id, 'approve' );234 $redir = add_query_arg( array( 'approved' => 1 ), $redir );235 } else {236 wp_set_comment_status( $comment_id, 'hold' );237 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir );238 }239 240 wp_redirect( $redir );241 242 exit();243 break;244 245 258 case 'editedcomment' : 246 259 247 260 $comment_id = absint( $_POST['comment_ID'] ); -
edit-comments.php
126 126 </h2> 127 127 128 128 <?php 129 if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) ) { 130 $approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0; 131 $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0; 132 $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0; 133 $untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0; 134 $spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0; 135 $unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0; 129 if ( isset( $_GET['error'] ) ) { 130 switch ( $_GET['error'] ) { 131 case 'id' : 132 $error_message = __('Oops, no comment with this ID.'); 133 break; 134 case 'cap' : 135 $error_message = __('You are not allowed to edit comments on this post.'); 136 break; 137 } 138 139 if ( isset( $error_message ) ) { ?> 140 <div id="moderated" class="error"><p><?php echo $error_message; ?></p></div> 141 <?php } 142 } 136 143 137 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 ) { 138 echo '<div id="moderated" class="updated"><p>'; 144 if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) || isset($_GET['same']) ) { 145 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; 146 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; 147 $trashed = isset( $_GET['trashed'] ) ? (int) $_GET['trashed'] : 0; 148 $untrashed = isset( $_GET['untrashed'] ) ? (int) $_GET['untrashed'] : 0; 149 $spammed = isset( $_GET['spammed'] ) ? (int) $_GET['spammed'] : 0; 150 $unspammed = isset( $_GET['unspammed'] ) ? (int) $_GET['unspammed'] : 0; 151 $same = isset( $_GET['same'] ) ? (int) $_GET['same'] : 0; 139 152 140 if ( $approved > 0 ) { 141 printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); 142 echo '<br />'; 143 } 153 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { 154 $messages = array(); 155 156 if ( $approved > 0 ) 157 $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); 158 144 159 if ( $spammed > 0 ) { 145 printf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed );146 160 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 147 echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';161 $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a>'; 148 162 } 149 if ( $unspammed > 0 ) { 150 printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );151 echo '<br />';152 } 163 164 if ( $unspammed > 0 ) 165 $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); 166 153 167 if ( $trashed > 0 ) { 154 printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed );155 168 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 156 echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';169 $messages[] = sprintf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a>'; 157 170 } 158 if ( $untrashed > 0 ) { 159 printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed ); 160 echo '<br />'; 171 172 if ( $untrashed > 0 ) 173 $messages[] = sprintf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed ); 174 175 if ( $deleted > 0 ) 176 $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); 177 178 if ( $same > 0 ) { 179 if ( $comment = get_comment( $same ) ) { 180 switch ( $comment->comment_approved ) { 181 case '1' : 182 $message_same = __( 'This comment is already approved.' ); 183 break; 184 case 'trash' : 185 $message_same = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>'; 186 break; 187 case 'spam' : 188 $message_same = __( 'This comment is already marked as spam.' ); 189 break; 190 } 191 if ( isset($message_same) && in_array( $comment->comment_approved, array( '1', 'spam' ) ) ) 192 $messages[] = $message_same . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>' ; 193 } 161 194 } 162 if ( $deleted > 0 ) { 163 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); 164 echo '<br />'; 195 if ( sizeof( $messages ) > 0 ) { 196 ?> 197 <div id="moderated" class="updated"><p> 198 <?php echo implode( "<br/>\n", $messages ); ?> 199 </p></div> 200 <?php 165 201 } 166 167 echo '</p></div>';168 202 } 169 203 } 170 204 ?>