home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / comment.php < prev    next >
Encoding:
PHP Script  |  2008-05-28  |  6.8 KB  |  229 lines

  1. <?php
  2. require_once('admin.php');
  3.  
  4. $parent_file = 'edit-comments.php';
  5. $submenu_file = 'edit-comments.php';
  6.  
  7. wp_reset_vars( array('action') );
  8.  
  9. if ( isset( $_POST['deletecomment'] ) )
  10.     $action = 'deletecomment';
  11.  
  12. function comment_footer_die( $msg ) {  // $msg is assumed to contain HTML and be sanitized
  13.     echo "<div class='wrap'><p>$msg</p></div>";
  14.     include('admin-footer.php');
  15.     die;
  16. }
  17.  
  18. switch( $action ) {
  19.  
  20. case 'editcomment' :
  21.     $title = __('Edit Comment');
  22.  
  23.     wp_enqueue_script('comment');
  24.  
  25.     require_once('admin-header.php');
  26.  
  27.     $comment_id = absint( $_GET['c'] );
  28.  
  29.     if ( !$comment = get_comment( $comment_id ) )
  30.         comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') );
  31.  
  32.     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
  33.         comment_footer_die( __('You are not allowed to edit comments on this post.') );
  34.  
  35.     $comment = get_comment_to_edit( $comment_id );
  36.  
  37.     include('edit-form-comment.php');
  38.  
  39.     break;
  40.  
  41. case 'cdc' :
  42. case 'mac' :
  43.  
  44.     require_once('admin-header.php');
  45.  
  46.     $comment_id = absint( $_GET['c'] );
  47.     $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment';
  48.     $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
  49.     $nonce_action .= $comment_id;
  50.  
  51.     if ( !$comment = get_comment_to_edit( $comment_id ) )
  52.         comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
  53.  
  54.     if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
  55.         comment_footer_die( 'cdc' == $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.') );
  56. ?>
  57. <div class='wrap'>
  58.  
  59. <div class="narrow">
  60. <?php
  61. if ( 'spam' == $_GET['dt'] ) {
  62.     $caution_msg = __('You are about to mark the following comment as spam:');
  63.     $button = __('Spam Comment');
  64. } elseif ( 'cdc' == $action ) {
  65.     $caution_msg = __('You are about to delete the following comment:');
  66.     $button = __('Delete Comment');
  67. } else {
  68.     $caution_msg = __('You are about to approve the following comment:');
  69.     $button = __('Approve Comment');
  70. }
  71. ?>
  72.  
  73. <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
  74.  
  75. <p><?php _e('Are you sure you want to do that?'); ?></p>
  76.  
  77. <form action='comment.php' method='get'>
  78.  
  79. <table width="100%">
  80. <tr>
  81. <td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>" /></td>
  82. <td class="textright"><input type='submit' class="button" value='<?php echo $button; ?>' /></td>
  83. </tr>
  84. </table>
  85.  
  86. <?php wp_nonce_field( $nonce_action ); ?>
  87. <input type='hidden' name='action' value='<?php echo $formaction; ?>' />
  88. <?php if ( 'spam' == $_GET['dt'] ) { ?>
  89. <input type='hidden' name='dt' value='spam' />
  90. <?php } ?>
  91. <input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
  92. <input type='hidden' name='c' value='<?php echo $comment->comment_ID; ?>' />
  93. <input type='hidden' name='noredir' value='1' />
  94. </form>
  95.  
  96. <table class="form-table" cellpadding="5">
  97. <tr class="alt">
  98. <th scope="row"><?php _e('Author'); ?></th>
  99. <td><?php echo $comment->comment_author; ?></td>
  100. </tr>
  101. <?php if ( $comment->comment_author_email ) { ?>
  102. <tr>
  103. <th scope="row"><?php _e('E-mail'); ?></th>
  104. <td><?php echo $comment->comment_author_email; ?></td>
  105. </tr>
  106. <?php } ?>
  107. <?php if ( $comment->comment_author_url ) { ?>
  108. <tr>
  109. <th scope="row"><?php _e('URL'); ?></th>
  110. <td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td>
  111. </tr>
  112. <?php } ?>
  113. <tr>
  114. <th scope="row" valign="top"><?php _e('Comment'); ?></th>
  115. <td><?php echo $comment->comment_content; ?></td>
  116. </tr>
  117. </table>
  118.  
  119. </div>
  120. </div>
  121. <?php
  122.     break;
  123.  
  124. case 'deletecomment' :
  125.     $comment_id = absint( $_REQUEST['c'] );
  126.     check_admin_referer( 'delete-comment_' . $comment_id );
  127.  
  128.     if ( isset( $_REQUEST['noredir'] ) )
  129.         $noredir = true;
  130.     else
  131.         $noredir = false;
  132.  
  133.     if ( !$comment = get_comment( $comment_id ) )
  134.         comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
  135.  
  136.     if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
  137.         comment_footer_die( __('You are not allowed to edit comments on this post.') );
  138.  
  139.     if ( 'spam' == $_REQUEST['dt'] )
  140.         wp_set_comment_status( $comment->comment_ID, 'spam' );
  141.     else
  142.         wp_delete_comment( $comment->comment_ID );
  143.  
  144.     if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) )
  145.         wp_redirect( wp_get_referer() );
  146.     else if ( '' != wp_get_original_referer() && false == $noredir )
  147.         wp_redirect( wp_get_original_referer() );
  148.     else
  149.         wp_redirect( admin_url('edit-comments.php') );
  150.  
  151.     die;
  152.     break;
  153.  
  154. case 'unapprovecomment' :
  155.     $comment_id = absint( $_GET['c'] );
  156.     check_admin_referer( 'unapprove-comment_' . $comment_id );
  157.  
  158.     if ( isset( $_GET['noredir'] ) )
  159.         $noredir = true;
  160.     else
  161.         $noredir = false;
  162.  
  163.     if ( !$comment = get_comment( $comment_id ) )
  164.         comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
  165.  
  166.     if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
  167.         comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
  168.  
  169.     wp_set_comment_status( $comment->comment_ID, 'hold' );
  170.  
  171.     if ( '' != wp_get_referer() && false == $noredir )
  172.         wp_redirect( wp_get_referer() );
  173.     else
  174.         wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
  175.  
  176.     exit();
  177.     break;
  178.  
  179. case 'approvecomment' :
  180.     $comment_id = absint( $_GET['c'] );
  181.     check_admin_referer( 'approve-comment_' . $comment_id );
  182.  
  183.     if ( isset( $_GET['noredir'] ) )
  184.         $noredir = true;
  185.     else
  186.         $noredir = false;
  187.  
  188.     if ( !$comment = get_comment( $comment_id ) )
  189.         comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
  190.  
  191.     if ( !current_user_can('edit_post', $comment->comment_post_ID) )
  192.         comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
  193.  
  194.     wp_set_comment_status( $comment->comment_ID, 'approve' );
  195.  
  196.     if ( '' != wp_get_referer() && false == $noredir )
  197.         wp_redirect( wp_get_referer() );
  198.     else
  199.         wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
  200.  
  201.     exit();
  202.     break;
  203.  
  204. case 'editedcomment' :
  205.  
  206.     $comment_id = absint( $_POST['comment_ID'] );
  207.     $comment_post_id = absint( $_POST['comment_post_id'] );
  208.  
  209.     check_admin_referer( 'update-comment_' . $comment_id );
  210.  
  211.     edit_comment();
  212.  
  213.     $location = ( empty( $_POST['referredby'] ) ? "edit.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
  214.     $location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
  215.     wp_redirect( $location );
  216.  
  217.     exit();
  218.     break;
  219.  
  220. default:
  221.     wp_die( __('Unknown action.') );
  222.     break;
  223.  
  224. } // end switch
  225.  
  226. include('admin-footer.php');
  227.  
  228. ?>
  229.