Make WordPress Core

Changeset 888


Ignore:
Timestamp:
02/17/2004 10:50:33 AM (21 years ago)
Author:
saxmatt
Message:

Fixes, deleting implemented.

File:
1 edited

Legend:

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

    r887 r888  
    3838<p><a href="?mode=view">View Mode</a> | <a href="?mode=edit">Mass Edit Mode</a></p>
    3939<?php
     40if (!empty($delete_comments)) {
     41
     42    // I had this all as one query but then realized we weren't checking permissions on each comment.
     43    $del_comments = ''; $safe_delete_commeents = ''; $i = 0;
     44    foreach ($delete_comments as $comment) { // Check the permissions on each
     45        $comment = intval($comment);
     46        $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $tablecomments WHERE comment_ID = $comment");
     47        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $post_id"));
     48        if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
     49            $wpdb->query("DELETE FROM $tablecomments WHERE comment_ID = $comment");
     50            ++$i;
     51        }
     52    }
     53    echo "<div class='wrap'><p>$i comments deleted.</p></div>";
     54}
     55
    4056if ($s) {
    4157    $s = $wpdb->escape($s);
     
    5470        echo '<ol>';
    5571        foreach ($comments as $comment) {
     72        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID"));
    5673            $comment_status = wp_get_comment_status($comment->comment_ID);
    5774            if ('unapproved' == $comment_status) {
     
    87104    } // end if ($comments)
    88105} elseif ('edit' == $mode) {
     106
    89107    if ($comments) {
    90108        echo '<form name="deletecomments" id="deletecomments" action="" method="post">
     
    96114    <th scope="col">IP</th>
    97115    <th scope="col">Comment Excerpt</th>
     116    <th scope="col">View</th>
    98117    <th scope="col">Edit</th>
    99118    <th scope="col">Delete</th>
    100119  </tr>';
    101120        foreach ($comments as $comment) {
     121        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID"));
    102122        $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee';
    103123?>
    104124  <tr style='background-color: <?php echo $bgcolor; ?>'>
    105     <td><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /></td>
     125    <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>
    106126    <th scope="row"><?php comment_author_link() ?></th>
    107127    <td><?php comment_author_email_link() ?></td>
    108128    <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
    109129    <td><?php comment_excerpt(); ?></td>
     130    <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit">View</a></td>
    110131    <td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
    111132                echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>Edit</a>"; } ?></td>
     
    121142<?php
    122143    } else {
    123 
    124         ?>
    125         <p>
    126         <strong>No results found.</strong>
    127         </p>
    128        
    129         <?php
     144?>
     145<p>
     146<strong>No results found.</strong>
     147</p>
     148<?php
    130149    } // end if ($comments)
    131150}
Note: See TracChangeset for help on using the changeset viewer.