]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/moderation.php
66fd75c6c9ae0f64ade34bfd268e0455820f9eec
[autoinstalls/wordpress.git] / wp-admin / moderation.php
1 <?php
2 require_once('admin.php');
3
4 $title = __('Moderate comments');
5 $parent_file = 'edit.php';
6 $list_js = true;
7
8 $wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
10         $wpvar = $wpvarstoreset[$i];
11         if (!isset($$wpvar)) {
12                 if (empty($_POST["$wpvar"])) {
13                         if (empty($_GET["$wpvar"])) {
14                                 $$wpvar = '';
15                         } else {
16                                 $$wpvar = $_GET["$wpvar"];
17                         }
18                 } else {
19                         $$wpvar = $_POST["$wpvar"];
20                 }
21         }
22 }
23
24 $comment = array();
25 if (isset($_POST["comment"])) {
26         foreach ($_POST["comment"] as $k => $v) {
27                 $comment[intval($k)] = $v;
28         }
29 }
30
31 switch($action) {
32
33 case 'update':
34
35         check_admin_referer('moderate-comments');
36
37         if ( ! current_user_can('moderate_comments') )
38         die('<p>'.__('Your level is not high enough to moderate comments.').'</p>');
39
40         $item_ignored = 0;
41         $item_deleted = 0;
42         $item_approved = 0;
43         $item_spam = 0;
44
45         foreach($comment as $key => $value) {
46         if ($feelinglucky && 'later' == $value)
47                 $value = 'delete';
48             switch($value) {
49                         case 'later':
50                                 // do nothing with that comment
51                                 // wp_set_comment_status($key, "hold");
52                                 ++$item_ignored;
53                                 break;
54                         case 'delete':
55                                 wp_set_comment_status($key, 'delete');
56                                 ++$item_deleted;
57                                 break;
58                         case 'spam':
59                                 wp_set_comment_status($key, 'spam');
60                                 ++$item_spam;
61                                 break;
62                         case 'approve':
63                                 wp_set_comment_status($key, 'approve');
64                                 if ( get_settings('comments_notify') == true ) {
65                                         wp_notify_postauthor($key);
66                                 }
67                                 ++$item_approved;
68                                 break;
69             }
70         }
71
72         $file = basename(__FILE__);
73         wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
74         exit();
75
76 break;
77
78 default:
79
80 require_once('admin-header.php');
81
82 if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) {
83         echo "<div id='moderated' class='updated fade'>\n<p>";
84         $approved = (int) $_GET['approved'];
85         $deleted  = (int) $_GET['deleted'];
86         $ignored  = (int) $_GET['ignored'];
87         $spam     = (int) $_GET['spam'];
88         if ($approved) {
89                 if ('1' == $approved) {
90                         echo __("1 comment approved") . " <br/>\n";
91                 } else {
92                  echo sprintf(__("%s comments approved <br />"), $approved) . "\n";
93                 }
94         }
95         if ($deleted) {
96                 if ('1' == $deleted) {
97                         echo __("1 comment deleted") . " <br/>\n";
98                 } else {
99                         echo sprintf(__("%s comments deleted"), $deleted) . " <br/>\n";
100                 }
101         }
102         if ($spam) {
103                 if ('1' == $spam) {
104                         echo __("1 comment marked as spam") . " <br/>\n";
105                 } else {
106                         echo sprintf(__("%s comments marked as spam"), $spam) . " <br/>\n";
107                 }
108         }
109         if ($ignored) {
110                 if ('1' == $ignored) {
111                         echo __("1 comment unchanged") . " <br/>\n";
112                 } else {
113                         echo sprintf(__("%s comments unchanged"), $ignored) . " <br/>\n";
114                 }
115         }
116         echo "</p></div>\n";
117 }
118
119 ?>
120         
121 <div class="wrap">
122
123 <?php
124 if ( current_user_can('moderate_comments') )
125         $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
126 else
127         $comments = '';
128
129 if ($comments) {
130     // list all comments that are waiting for approval
131     $file = basename(__FILE__);
132 ?>
133     <h2><?php _e('Moderation Queue') ?></h2>
134     <form name="approval" action="moderation.php" method="post">
135     <?php wp_nonce_field('moderate-comments') ?>
136     <input type="hidden" name="action" value="update" />
137     <ol id="the-list" class="commentlist">
138 <?php
139 $i = 0;
140     foreach($comments as $comment) {
141         ++$i;
142         $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
143         $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
144         if ($i % 2) $class = 'class="alternate"';
145         else $class = '';
146         echo "\n\t<li id='comment-$comment->comment_ID' $class>"; 
147         ?>
148         <p><strong><?php _e('Name:') ?></strong> <?php comment_author_link() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a> | <strong><?php _e('Date:') ?></strong> <?php comment_date(); ?></p>
149 <?php comment_text() ?>
150 <p><?php
151 echo '<a href="post.php?action=editcomment&amp;comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';?>
152 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a> | 
153 <?php 
154 echo " <a href=\"" . wp_nonce_url("post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . __("You are about to delete this comment.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete.") . "' );\">" . __('Delete just this comment') . "</a> | "; ?>  <?php _e('Bulk action:') ?>
155         <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>
156         <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>
157         <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>
158         <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>
159         </p>
160
161         </li>
162 <?php
163     }
164 ?>
165     </ol>
166
167 <div id="ajax-response"></div>
168
169     <p class="submit"><input type="submit" name="submit" value="<?php _e('Moderate Comments &raquo;') ?>" /></p>
170 <script type="text/javascript">
171 // <![CDATA[
172 function markAllForDelete() {
173         for (var i=0; i< document.approval.length; i++) {
174                 if (document.approval[i].value == "delete") {
175                         document.approval[i].checked = true;
176                 }
177         }
178 }
179 function markAllForApprove() {
180         for (var i=0; i< document.approval.length; i++) {
181                 if (document.approval[i].value == "approve") {
182                         document.approval[i].checked = true;
183                 }
184         }
185 }
186 function markAllForDefer() {
187         for (var i=0; i< document.approval.length; i++) {
188                 if (document.approval[i].value == "later") {
189                         document.approval[i].checked = true;
190                 }
191         }
192 }
193 function markAllAsSpam() {
194         for (var i=0; i< document.approval.length; i++) {
195                 if (document.approval[i].value == "spam") {
196                         document.approval[i].checked = true;
197                 }
198         }
199 }
200 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>');
201 // ]]>
202 </script>
203
204 <noscript>
205         <p>
206                 <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
207         </p>
208 </noscript>
209     </form>
210 <?php
211 } else {
212     // nothing to approve
213         echo '<p>'.__("Currently there are no comments for you to moderate.") . "</p>\n";
214 }
215 ?>
216
217 </div>
218
219 <?php
220
221 break;
222 }
223
224
225 include('admin-footer.php') ?>