-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete-blocked-users-admin.php
More file actions
60 lines (51 loc) · 1.76 KB
/
delete-blocked-users-admin.php
File metadata and controls
60 lines (51 loc) · 1.76 KB
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
<?php
require_once QA_INCLUDE_DIR . 'db/users.php';
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'app/posts.php';
class delete_blocked_users_admin
{
public function admin_form(&$qa_content)
{
$ok = null;
$deleted = 0;
if (qa_clicked('delete_blocked_users_submit')) {
$users = qa_db_read_all_assoc(
qa_db_query_sub(
"SELECT userid FROM ^users WHERE (flags & #) != 0",
QA_USER_FLAGS_USER_BLOCKED
)
);
foreach ($users as $user) {
$userid = $user['userid'];
$posts = qa_db_read_all_assoc(
qa_db_query_sub(
"SELECT postid FROM ^posts WHERE userid = #",
$userid
)
);
foreach ($posts as $post) {
qa_post_delete($post['postid']);
}
qa_db_user_delete($userid);
$deleted++;
}
$ok = "$deleted blocked users have been deleted.";
}
return array(
'ok' => $ok,
'fields' => array(
array(
'label' => 'Delete all blocked users',
'type' => 'static',
'value' => 'This removes ALL users who are currently marked as blocked, including their posts.',
)
),
'buttons' => array(
array(
'label' => 'Delete blocked users now',
'tags' => 'name="delete_blocked_users_submit" onclick="return confirm(\'Really delete all blocked users?\')"',
),
),
);
}
}