mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 14:28:56 +00:00
Merge remote-tracking branch 'prototech/ticket/11507' into develop
* prototech/ticket/11507: [ticket/11507] Handle empty sets correctly. [ticket/11507] Allow group & unapproved post count options to be used alone. [ticket/11507] Fix the unapproved posts count query. [ticket/11507] Allow the posts awaiting approval value to be 0.
This commit is contained in:
commit
f58add8d79
1 changed files with 46 additions and 29 deletions
|
@ -358,12 +358,12 @@ class acp_prune
|
||||||
*/
|
*/
|
||||||
function get_prune_users(&$user_ids, &$usernames)
|
function get_prune_users(&$user_ids, &$usernames)
|
||||||
{
|
{
|
||||||
global $user, $db;
|
global $user, $db, $request;
|
||||||
|
|
||||||
$users_by_name = request_var('users', '', true);
|
$users_by_name = request_var('users', '', true);
|
||||||
$users_by_id = request_var('user_ids', array(0));
|
$users_by_id = request_var('user_ids', array(0));
|
||||||
$group_id = request_var('group_id', 0);
|
$group_id = request_var('group_id', 0);
|
||||||
$posts_on_queue = request_var('posts_on_queue', 0);
|
$posts_on_queue = (trim($request->variable('posts_on_queue', '')) === '') ? false : $request->variable('posts_on_queue', 0);
|
||||||
|
|
||||||
if ($users_by_name)
|
if ($users_by_name)
|
||||||
{
|
{
|
||||||
|
@ -450,8 +450,8 @@ class acp_prune
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protect the admin, do not prune if no options are given...
|
// If no search criteria were provided, go no further.
|
||||||
if (!$where_sql)
|
if (!$where_sql && !$group_id && $posts_on_queue === false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -468,34 +468,40 @@ class acp_prune
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// Do not prune founder members
|
// Protect the admin, do not prune if no options are given...
|
||||||
$sql = 'SELECT user_id, username
|
if ($where_sql)
|
||||||
FROM ' . USERS_TABLE . '
|
|
||||||
WHERE user_id <> ' . ANONYMOUS . '
|
|
||||||
AND user_type <> ' . USER_FOUNDER . "
|
|
||||||
$where_sql";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$user_ids = $usernames = array();
|
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
{
|
||||||
// Do not prune bots and the user currently pruning.
|
// Do not prune founder members
|
||||||
if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
|
$sql = 'SELECT user_id, username
|
||||||
|
FROM ' . USERS_TABLE . '
|
||||||
|
WHERE user_id <> ' . ANONYMOUS . '
|
||||||
|
AND user_type <> ' . USER_FOUNDER . "
|
||||||
|
$where_sql";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$user_ids = $usernames = array();
|
||||||
|
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$user_ids[] = $row['user_id'];
|
// Do not prune bots and the user currently pruning.
|
||||||
$usernames[$row['user_id']] = $row['username'];
|
if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
|
||||||
|
{
|
||||||
|
$user_ids[] = $row['user_id'];
|
||||||
|
$usernames[$row['user_id']] = $row['username'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
if ($group_id)
|
if ($group_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT u.user_id, u.username
|
$sql = 'SELECT u.user_id, u.username
|
||||||
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
|
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
|
||||||
WHERE ug.group_id = ' . (int) $group_id . '
|
WHERE ug.group_id = ' . (int) $group_id . '
|
||||||
AND ug.user_pending = 0
|
AND ug.user_id <> ' . ANONYMOUS . '
|
||||||
AND ' . $db->sql_in_set('ug.user_id', $user_ids, false, true) . '
|
AND u.user_type <> ' . USER_FOUNDER . '
|
||||||
|
AND ug.user_pending = 0 ' .
|
||||||
|
((!empty($user_ids)) ? 'AND ' . $db->sql_in_set('ug.user_id', $user_ids) : '') . '
|
||||||
AND u.user_id = ug.user_id';
|
AND u.user_id = ug.user_id';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
@ -505,28 +511,39 @@ class acp_prune
|
||||||
$user_ids = $usernames = array();
|
$user_ids = $usernames = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$user_ids[] = $row['user_id'];
|
// Do not prune bots and the user currently pruning.
|
||||||
$usernames[$row['user_id']] = $row['username'];
|
if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
|
||||||
|
{
|
||||||
|
$user_ids[] = $row['user_id'];
|
||||||
|
$usernames[$row['user_id']] = $row['username'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($posts_on_queue)
|
if ($posts_on_queue !== false)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts
|
$sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
||||||
WHERE ' . $db->sql_in_set('p.poster_id', $user_ids, false, true) . '
|
WHERE u.user_id <> ' . ANONYMOUS . '
|
||||||
|
AND u.user_type <> ' . USER_FOUNDER .
|
||||||
|
((!empty($user_ids)) ? 'AND ' . $db->sql_in_set('p.poster_id', $user_ids) : '') . '
|
||||||
|
AND p.post_visibility = ' . ITEM_UNAPPROVED . '
|
||||||
AND u.user_id = p.poster_id
|
AND u.user_id = p.poster_id
|
||||||
GROUP BY p.poster_id
|
GROUP BY p.poster_id
|
||||||
HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue;
|
HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue;
|
||||||
$result = $db->sql_query($result);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
// same intersection logic as the above group ID portion
|
// same intersection logic as the above group ID portion
|
||||||
$user_ids = $usernames = array();
|
$user_ids = $usernames = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$user_ids[] = $row['user_id'];
|
// Do not prune bots and the user currently pruning.
|
||||||
$usernames[$row['user_id']] = $row['username'];
|
if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
|
||||||
|
{
|
||||||
|
$user_ids[] = $row['user_id'];
|
||||||
|
$usernames[$row['user_id']] = $row['username'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue