Changeset 6999

Show
Ignore:
Timestamp:
02/24/08 02:33:30 (7 months ago)
Author:
ryan
Message:

Hook up bulk comment operations.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/edit-comments.php

    r6994 r6999  
    77wp_enqueue_script('admin-forms'); 
    88 
    9 if ( !empty( $_POST['delete_comments'] ) ) : 
     9if ( !empty( $_REQUEST['delete_comments'] ) ) : 
    1010    check_admin_referer('bulk-comments'); 
    1111 
    12     $i = 0; 
    13     foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each 
     12    $comments_deleted = $comments_approved = $comments_spammed = 0;  
     13    foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each 
    1414        $comment = (int) $comment; 
    1515        $post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); 
    1616        // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); 
    17         if ( current_user_can('edit_post', $post_id) ) { 
    18             if ( !empty( $_POST['spam_button'] ) ) 
    19                 wp_set_comment_status($comment, 'spam'); 
    20             else 
    21                 wp_set_comment_status($comment, 'delete'); 
    22             ++$i; 
     17        if ( !current_user_can('edit_post', $post_id) ) 
     18            continue; 
     19        if ( !empty( $_REQUEST['spamit'] ) ) { 
     20            wp_set_comment_status($comment, 'spam'); 
     21            $comments_spammed++; 
     22        } elseif ( !empty( $_REQUEST['deleteit'] ) ) { 
     23            wp_set_comment_status($comment, 'delete'); 
     24            $comments_deleted++; 
     25        } elseif ( !empty( $_REQUEST['approveit'] ) ) { 
     26            wp_set_comment_status($comment, 'approve'); 
     27            $comments_approved++; 
    2328        } 
    2429    endforeach; 
    25     /* 
    26     echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; 
    27     if ( !empty( $_POST['spam_button'] ) ) { 
    28         printf(__ngettext('%s comment marked as spam.', '%s comments marked as spam.', $i), $i); 
    29     } else { 
    30         printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i); 
    31     } 
    32     echo '</p></div>'; 
    33     */ 
    34     // TODO redirect with message 
     30    wp_redirect( basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed ); 
    3531endif; 
    3632 
     
    6763?> 
    6864</ul> 
     65 
     66<?php 
     67if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) { 
     68    $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; 
     69    $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; 
     70    $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0; 
     71 
     72    if ( $approved > 0 || $deleted > 0 || $spam > 0 ) { 
     73        echo '<div id="moderated" class="updated fade"><p>'; 
     74 
     75        if ( $approved > 0 ) { 
     76            printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved ); 
     77            echo '<br />'; 
     78        } 
     79 
     80        if ( $deleted > 0 ) { 
     81            printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); 
     82            echo '<br />'; 
     83        } 
     84 
     85        if ( $spam > 0 ) { 
     86            printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); 
     87            echo '<br />'; 
     88        } 
     89 
     90        echo '</p></div>'; 
     91    } 
     92} 
     93?> 
    6994 
    7095<p id="post-search">