[ Index ] |
|
Code source de WordPress 2.1.2 |
1 <?php 2 require_once ('admin.php'); 3 4 $title = __('Moderate comments'); 5 $parent_file = 'edit-comments.php'; 6 wp_enqueue_script( 'admin-comments' ); 7 8 wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky')); 9 10 $comment = array(); 11 if (isset($_POST["comment"])) { 12 foreach ($_POST["comment"] as $k => $v) { 13 $comment[intval($k)] = $v; 14 } 15 } 16 17 switch($action) { 18 19 case 'update': 20 21 check_admin_referer('moderate-comments'); 22 23 if ( !current_user_can('moderate_comments') ) 24 wp_die(__('Your level is not high enough to moderate comments.')); 25 26 $item_ignored = 0; 27 $item_deleted = 0; 28 $item_approved = 0; 29 $item_spam = 0; 30 31 foreach($comment as $key => $value) { 32 if ($feelinglucky && 'later' == $value) 33 $value = 'delete'; 34 switch($value) { 35 case 'later': 36 // do nothing with that comment 37 // wp_set_comment_status($key, "hold"); 38 ++$item_ignored; 39 break; 40 case 'delete': 41 wp_set_comment_status($key, 'delete'); 42 ++$item_deleted; 43 break; 44 case 'spam': 45 wp_set_comment_status($key, 'spam'); 46 ++$item_spam; 47 break; 48 case 'approve': 49 wp_set_comment_status($key, 'approve'); 50 if ( get_option('comments_notify') == true ) { 51 wp_notify_postauthor($key); 52 } 53 ++$item_approved; 54 break; 55 } 56 } 57 58 $file = basename(__FILE__); 59 wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam"); 60 exit(); 61 62 break; 63 64 default: 65 66 require_once ('admin-header.php'); 67 68 if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) { 69 echo "<div id='moderated' class='updated fade'>\n<p>"; 70 $approved = (int) $_GET['approved']; 71 $deleted = (int) $_GET['deleted']; 72 $ignored = (int) $_GET['ignored']; 73 $spam = (int) $_GET['spam']; 74 if ($approved) { 75 printf(__ngettext('%s comment approved', '%s comments approved', $approved), $approved); 76 echo "<br/>\n"; 77 } 78 if ($deleted) { 79 printf(__ngettext('%s comment deleted', '%s comments deleted', $deleted), $deleted); 80 echo "<br/>\n"; 81 } 82 if ($spam) { 83 printf(__ngettext('%s comment marked as spam', '%s comments marked as spam', $spam), $spam); 84 echo "<br/>\n"; 85 } 86 if ($ignored) { 87 printf(__ngettext('%s comment unchanged', '%s comments unchanged', $ignored), $ignored); 88 echo "<br/>\n"; 89 } 90 echo "</p></div>\n"; 91 } 92 93 ?> 94 95 <div class="wrap"> 96 97 <?php 98 if ( current_user_can('moderate_comments') ) 99 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'"); 100 else 101 $comments = ''; 102 103 if ($comments) { 104 // list all comments that are waiting for approval 105 $file = basename(__FILE__); 106 ?> 107 <h2><?php _e('Moderation Queue') ?></h2> 108 <form name="approval" action="moderation.php" method="post"> 109 <?php wp_nonce_field('moderate-comments') ?> 110 <input type="hidden" name="action" value="update" /> 111 <ol id="the-comment-list" class="commentlist"> 112 <?php 113 $i = 0; 114 foreach($comments as $comment) { 115 ++$i; 116 $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date); 117 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'"); 118 if ($i % 2) $class = 'js-unapproved alternate'; 119 else $class = 'js-unapproved'; 120 echo "\n\t<li id='comment-$comment->comment_ID' class='$class'>"; 121 ?> 122 <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 123 <?php comment_text() ?> 124 <p><?php comment_date('M j, g:i A'); ?> — [ <?php 125 echo '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'">' . __('Edit') . '</a> | '; 126 echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> | "; ?> 127 <?php 128 $post = get_post($comment->comment_post_ID); 129 $post_title = wp_specialchars( $post->post_title, 'double' ); 130 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 131 ?> 132 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] — 133 <?php _e('Bulk action:') ?> 134 <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> 135 <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> 136 <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-delete" value="delete" /> <label for="comment-<?php echo $comment->comment_ID; ?>-delete"><?php _e('Delete') ?></label> 137 <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-nothing" value="later" checked="checked" /> <label for="comment-<?php echo $comment->comment_ID; ?>-nothing"><?php _e('Defer until later') ?></label> 138 </p> 139 140 </li> 141 <?php 142 } 143 ?> 144 </ol> 145 146 <div id="ajax-response"></div> 147 148 <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments »') ?>" /></p> 149 <script type="text/javascript"> 150 // <![CDATA[ 151 function markAllForDelete() { 152 for (var i=0; i< document.approval.length; i++) { 153 if (document.approval[i].value == "delete") { 154 document.approval[i].checked = true; 155 } 156 } 157 } 158 function markAllForApprove() { 159 for (var i=0; i< document.approval.length; i++) { 160 if (document.approval[i].value == "approve") { 161 document.approval[i].checked = true; 162 } 163 } 164 } 165 function markAllForDefer() { 166 for (var i=0; i< document.approval.length; i++) { 167 if (document.approval[i].value == "later") { 168 document.approval[i].checked = true; 169 } 170 } 171 } 172 function markAllAsSpam() { 173 for (var i=0; i< document.approval.length; i++) { 174 if (document.approval[i].value == "spam") { 175 document.approval[i].checked = true; 176 } 177 } 178 } 179 document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllAsSpam()"><?php _e('Mark all as spam'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>'); 180 // ]]> 181 </script> 182 183 <noscript> 184 <p> 185 <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can’t be undone.</strong>'); ?></label> 186 </p> 187 </noscript> 188 </form> 189 <?php 190 } else { 191 // nothing to approve 192 echo '<p>'.__("Currently there are no comments for you to moderate.") . "</p>\n"; 193 } 194 ?> 195 196 </div> 197 198 <?php 199 200 break; 201 } 202 203 204 include ('admin-footer.php'); 205 206 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 19:41:27 2007 | par Balluche grâce à PHPXref 0.7 |