forked from joseconti/WangGuard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwangguard-queue.php
107 lines (107 loc) · 4.86 KB
/
wangguard-queue.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
//WangGuard Queue
function wangguard_queue() {
global $wpdb;
if ( !current_user_can('level_10') )
die(__('Cheatin’ uh?', 'wangguard'));
include 'wangguard-class-wp-queue.php';
$wp_list_table = new WangGuard_Queue_Table();
$pagenum = $wp_list_table->get_pagenum();
$messages = array();
switch ( $wp_list_table->current_action() ) {
case 'unreport':
if (!wp_verify_nonce($_REQUEST['_wpnonce'], "bulk-reports" )) die("bad nonce");
//remove selected blogs from the queue
$removedBlogs = 0;
$blogs = (array)$_REQUEST['blogs'];
foreach ($blogs as $blogid) {
$blogid = (int)$blogid;
$table_name = $wpdb->base_prefix . "wangguardreportqueue";
$wpdb->query( $wpdb->prepare("delete from $table_name where blog_id = '%d'" , $blogid ) );
$removedBlogs++;
}
//remove selected users from the queue
$removedUsers = 0;
$users = (array)$_REQUEST['users'];
foreach ($users as $userid) {
$userid = (int)$userid;
$table_name = $wpdb->base_prefix . "wangguardreportqueue";
$wpdb->query( $wpdb->prepare("delete from $table_name where ID = '%d'" , $userid ) );
$removedUsers++;
}
if ($removedBlogs)
$messages[] = '<div id="message" class="updated fade"><p><strong>'. sprintf(__("%d blog(s) were removed from the WangGuard Moderation Queue" , "wangguard") , $removedBlogs) .'</strong></p></div>';
if ($removedUsers)
$messages[] = '<div id="message" class="updated fade"><p><strong>'. sprintf(__("%d user(s) were removed from the WangGuard Moderation Queue" , "wangguard") , $removedUsers) .'</strong></p></div>';
break;
case 'reportassplog':
if (!wp_verify_nonce($_REQUEST['_wpnonce'], "bulk-reports" )) die("bad nonce");
//report selected blogs
$reportedBlogs = 0;
$reportedAuthors = 0;
$authors_ids = array();
$blogs = (array)$_REQUEST['blogs'];
$table_name = $wpdb->base_prefix . "wangguardreportqueue";
foreach ($blogs as $blogid) {
$blogid = (int)$blogid;
$reportedBlogs++;
//remove blog from queue (users are removed on the delete_user hook)
$wpdb->query( $wpdb->prepare("delete from $table_name where blog_id = '%d'" , $blogid ) );
//get the authors of each blog
$blog_prefix = $wpdb->get_blog_prefix( $blogid );
$authors = $wpdb->get_results( "SELECT user_id, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities'" );
foreach( (array)$authors as $author ) {
$caps = maybe_unserialize( $author->caps );
if ( !isset( $caps['administrator'] ) ) continue;
$authors_ids[] = $author->user_id;
}
}
$res = wangguard_report_users($authors_ids);
$resArr = explode(",", $res);
$reportedAuthors = (count($blogs)==0) ? 0 : count($resArr);
//report selected users
$reportedUsers = 0;
$users = (array)$_REQUEST['users'];
$res = wangguard_report_users($users);
$resArr = explode(",", $res);
$reportedUsers = (count($users)==0) ? 0 : count($resArr);
if ($reportedBlogs) {
if (get_site_option ("wangguard-delete-users-on-report")=='1')
$messages[] = '<div id="message" class="updated fade"><p><strong>'. sprintf(__("%d blog(s) and %d author(s) was reported as Splogger(s) and deleted" , "wangguard") , $reportedBlogs , $reportedAuthors) .'</strong></p></div>';
else
$messages[] = '<div id="message" class="updated fade"><p><strong>'. sprintf(__("%d blog(s) and %d author(s) was reported as Splogger(s)" , "wangguard") , $reportedBlogs , $reportedAuthors) .'</strong></p></div>';
}
if ($reportedUsers) {
if (get_site_option ("wangguard-delete-users-on-report")=='1')
$messages[] = '<div id="message" class="updated fade"><p><strong>'. sprintf(__("%d user(s) were reported as Splogger(s) and deleted" , "wangguard") , $reportedUsers) .'</strong></p></div>';
else
$messages[] = '<div id="message" class="updated fade"><p><strong>'. sprintf(__("%d user(s) were reported as Splogger(s)" , "wangguard") , $reportedUsers) .'</strong></p></div>';
}
break;
}
if ( count($messages) ) {
foreach ( $messages as $msg )
echo $msg;
} ?>
<div class="wrap" id="wangguard-queue-cont">
<div class="wangguard-confico"><img src="<?php echo WP_PLUGIN_URL ?>/wangguard/img/queue.png" alt="<?php echo htmlentities(__('WangGuard Moderation Queue', 'wangguard')) ?>" /></div>
<div class="icon32" id="icon-wangguard"><br></div>
<h2><?php _e('WangGuard Moderation Queue', 'wangguard'); ?></h2>
<form action="admin.php" method="get" id="wangguard-queue-form">
<input type="hidden" name="page" value="wangguard_queue" />
<?php
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
$wp_list_table->views();
$wp_list_table->display();
?>
</form>
<br class="clear" />
</div>
<?php
}
?>