Make WordPress Core


Ignore:
Timestamp:
11/12/2003 03:22:47 PM (23 years ago)
Author:
emc3
Message:

otaku42's comment moderation patches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/wp-post.php

    r528 r546  
    339339
    340340        $comment = $HTTP_GET_VARS['comment'];
    341         $commentdata = get_commentdata($comment, 1) or die('Oops, no comment with this ID. <a href="javascript:history.go(-1)">Go back</a>!');
     341        $commentdata = get_commentdata($comment, 1, true) or die('Oops, no comment with this ID. <a href="javascript:history.go(-1)">Go back</a>!');
    342342        $content = $commentdata['comment_content'];
    343343        $content = format_to_edit($content);
    … …  
    347347        break;
    348348
     349    case 'confirmdeletecomment':
     350   
     351        $standalone = 0;
     352        require_once('./b2header.php');
     353       
     354        if ($user_level == 0)
     355                die ('Cheatin&#8217; uh?');
     356       
     357        $comment = $HTTP_GET_VARS['comment'];
     358        $p = $HTTP_GET_VARS['p'];
     359        $commentdata = get_commentdata($comment, 1, true) or die('Oops, no comment with this ID. <a href="edit.php">Go back</a>!');
     360       
     361        echo "<div class=\"wrap\">\n";
     362        echo "<p><strong>Caution:</strong> You are about to delete the following comment:</p>\n";
     363        echo "<table border=\"0\">\n";
     364        echo "<tr><td>Author:</td><td>" . $commentdata["comment_author"] . "</td></tr>\n";
     365        echo "<tr><td>E-Mail:</td><td>" . $commentdata["comment_author_email"] . "</td></tr>\n";
     366        echo "<tr><td>URL:</td><td>" . $commentdata["comment_author_url"] . "</td></tr>\n";
     367        echo "<tr><td>Comment:</td><td>" . stripslashes($commentdata["comment_content"]) . "</td></tr>\n";
     368        echo "</table>\n";
     369        echo "<p>Are you sure you want to do that?</p>\n";
     370       
     371        echo "<form action=\"$siteurl/wp-admin/wp-post.php\" method=\"get\">\n";
     372        echo "<input type=\"hidden\" name=\"action\" value=\"deletecomment\" />\n";
     373        echo "<input type=\"hidden\" name=\"p\" value=\"$p\" />\n";
     374        echo "<input type=\"hidden\" name=\"comment\" value=\"$comment\" />\n";
     375        echo "<input type=\"hidden\" name=\"noredir\" value=\"1\" />\n";
     376        echo "<input type=\"submit\" value=\"Yes\" />";
     377        echo "&nbsp;&nbsp;";
     378        echo "<input type=\"button\" value=\"No\" onClick=\"self.location='$siteurl/wp-admin/edit.php?p=$p&c=1#comments';\" />\n";
     379        echo "</form>\n";
     380        echo "</div>\n";
     381       
     382        break;
     383
    349384    case 'deletecomment':
    350385
    351                 $standalone = 1;
    352                 require_once('./b2header.php');
    353 
    354                 if ($user_level == 0)
    355                         die ('Cheatin&#8217; uh?');
    356 
    357 
    358                 $comment = $HTTP_GET_VARS['comment'];
    359                 $p = $HTTP_GET_VARS['p'];
    360 
    361                 $postdata = get_postdata($p) or die('Oops, no post with this ID. <a href="wp-post.php">Go back</a>!');
    362                 $commentdata = get_commentdata($comment) or die('Oops, no comment with this ID. <a href="wp-post.php">Go back</a>!');
    363 
    364                 $authordata = get_userdata($postdata['Author_ID']);
    365                 if ($user_level < $authordata->user_level)
    366                         die ('You don&#8217;t have the right to delete <strong>'.$authordata->user_nickname.'</strong>&#8217;s post comments. <a href="wp-post.php">Go back</a>!');
    367 
    368                 $result = $wpdb->query("DELETE FROM $tablecomments WHERE comment_ID=$comment");
    369 
    370                 if($HTTP_SERVER_VARS['HTTP_REFERER'] != "") {
    371                         header('Location: ' . $HTTP_SERVER_VARS['HTTP_REFERER']);
    372                 } else {
    373                         header('Location: '.$siteurl.'/wp-admin/');
    374                 }
    375 
    376                 break;
    377 
     386        $standalone = 1;
     387        require_once('./b2header.php');
     388
     389        if ($user_level == 0)
     390                die ('Cheatin&#8217; uh?');
     391
     392
     393        $comment = $HTTP_GET_VARS['comment'];
     394        $p = $HTTP_GET_VARS['p'];
     395        if (isset($HTTP_GET_VARS['noredir'])) {
     396            $noredir = true;
     397        } else {
     398            $noredir = false;
     399        }
     400       
     401        $postdata = get_postdata($p) or die('Oops, no post with this ID. <a href="edit.php">Go back</a>!');
     402        $commentdata = get_commentdata($comment, 1, true) or die('Oops, no comment with this ID. <a href="wp-post.php">Go back</a>!');
     403
     404        $authordata = get_userdata($postdata['Author_ID']);
     405        if ($user_level < $authordata->user_level)
     406                die ('You don&#8217;t have the right to delete <strong>'.$authordata->user_nickname.'</strong>&#8217;s post comments. <a href="wp-post.php">Go back</a>!');
     407
     408        wp_set_comment_status($comment, "delete");
     409
     410        if (($HTTP_SERVER_VARS['HTTP_REFERER'] != "") && (false == $noredir)) {
     411                header('Location: ' . $HTTP_SERVER_VARS['HTTP_REFERER']);
     412        } else {
     413                header('Location: '.$siteurl.'/wp-admin/edit.php?p='.$p.'&c=1#comments');
     414        }
     415
     416        break;
     417       
     418    case 'unapprovecomment':
     419       
     420        $standalone = 1;
     421        require_once('./b2header.php');
     422       
     423        if ($user_level == 0)
     424                die ('Cheatin&#8217; uh?');
     425               
     426        $comment = $HTTP_GET_VARS['comment'];
     427        $p = $HTTP_GET_VARS['p'];
     428        if (isset($HTTP_GET_VARS['noredir'])) {
     429            $noredir = true;
     430        } else {
     431            $noredir = false;
     432        }
     433
     434        $commentdata = get_commentdata($comment) or die('Oops, no comment with this ID. <a href="edit.php">Go back</a>!');
     435       
     436        wp_set_comment_status($comment, "hold");
     437       
     438        if (($HTTP_SERVER_VARS['HTTP_REFERER'] != "") && (false == $noredir)) {
     439                header('Location: ' . $HTTP_SERVER_VARS['HTTP_REFERER']);
     440        } else {
     441                header('Location: '.$siteurl.'/wp-admin/edit.php?p='.$p.'&c=1#comments');
     442        }
     443       
     444        break;
     445       
     446    case 'mailapprovecomment':
     447   
     448        $standalone = 0;
     449        require_once('./b2header.php');
     450       
     451        if ($user_level == 0)
     452                die ('Cheatin&#8217; uh?');
     453       
     454        $comment = $HTTP_GET_VARS['comment'];
     455        $p = $HTTP_GET_VARS['p'];
     456        $commentdata = get_commentdata($comment, 1, true) or die('Oops, no comment with this ID. <a href="edit.php">Go back</a>!');
     457
     458        wp_set_comment_status($comment, "approve");
     459        if (get_settings("comments_notify") == true) {
     460                wp_notify_postauthor($comment);
     461        }
     462       
     463        echo "<div class=\"wrap\">\n";
     464        echo "<p>Comment has been approved.</p>\n";
     465       
     466        echo "<form action=\"$siteurl/wp-admin/edit.php?p=$p&c=1#comments\" method=\"get\">\n";
     467        echo "<input type=\"hidden\" name=\"p\" value=\"$p\" />\n";
     468        echo "<input type=\"hidden\" name=\"c\" value=\"1\" />\n";
     469        echo "<input type=\"submit\" value=\"Ok\" />";
     470        echo "</form>\n";
     471        echo "</div>\n";
     472       
     473        break;
     474
     475    case 'approvecomment':
     476   
     477        $standalone = 1;
     478        require_once('./b2header.php');
     479       
     480        if ($user_level == 0)
     481                die ('Cheatin&#8217; uh?');
     482               
     483        $comment = $HTTP_GET_VARS['comment'];
     484        $p = $HTTP_GET_VARS['p'];
     485        if (isset($HTTP_GET_VARS['noredir'])) {
     486            $noredir = true;
     487        } else {
     488            $noredir = false;
     489        }
     490        $commentdata = get_commentdata($comment) or die('Oops, no comment with this ID. <a href="edit.php">Go back</a>!');
     491       
     492        wp_set_comment_status($comment, "approve");
     493        if (get_settings("comments_notify") == true) {
     494                wp_notify_postauthor($comment);
     495        }
     496       
     497         
     498        if (($HTTP_SERVER_VARS['HTTP_REFERER'] != "") && (false == $noredir)) {
     499                header('Location: ' . $HTTP_SERVER_VARS['HTTP_REFERER']);
     500        } else {
     501                header('Location: '.$siteurl.'/wp-admin/edit.php?p='.$p.'&c=1#comments');
     502        }
     503       
     504        break;
     505       
    378506    case 'editedcomment':
    379507
Note: See TracChangeset for help on using the changeset viewer.