1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-13 20:28:44 +01: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:
Joas Schilling 2013-11-28 13:12:12 +01:00
commit f58add8d79

View File

@ -358,12 +358,12 @@ class acp_prune
*/
function get_prune_users(&$user_ids, &$usernames)
{
global $user, $db;
global $user, $db, $request;
$users_by_name = request_var('users', '', true);
$users_by_id = request_var('user_ids', array(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)
{
@ -450,8 +450,8 @@ class acp_prune
}
}
// Protect the admin, do not prune if no options are given...
if (!$where_sql)
// If no search criteria were provided, go no further.
if (!$where_sql && !$group_id && $posts_on_queue === false)
{
return;
}
@ -468,34 +468,40 @@ class acp_prune
}
$db->sql_freeresult($result);
// Do not prune founder members
$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))
// Protect the admin, do not prune if no options are given...
if ($where_sql)
{
// Do not prune bots and the user currently pruning.
if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
// Do not prune founder members
$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'];
$usernames[$row['user_id']] = $row['username'];
// Do not prune bots and the user currently pruning.
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)
{
$sql = 'SELECT u.user_id, u.username
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
WHERE ug.group_id = ' . (int) $group_id . '
AND ug.user_pending = 0
AND ' . $db->sql_in_set('ug.user_id', $user_ids, false, true) . '
AND ug.user_id <> ' . ANONYMOUS . '
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';
$result = $db->sql_query($sql);
@ -505,28 +511,39 @@ class acp_prune
$user_ids = $usernames = array();
while ($row = $db->sql_fetchrow($result))
{
$user_ids[] = $row['user_id'];
$usernames[$row['user_id']] = $row['username'];
// Do not prune bots and the user currently pruning.
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);
}
if ($posts_on_queue)
if ($posts_on_queue !== false)
{
$sql = 'SELECT u.user_id, u.username, COUNT(p.post_id) AS queue_posts
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
GROUP BY p.poster_id
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
$user_ids = $usernames = array();
while ($row = $db->sql_fetchrow($result))
{
$user_ids[] = $row['user_id'];
$usernames[$row['user_id']] = $row['username'];
// Do not prune bots and the user currently pruning.
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);
}