2005-12-10 23:20:21 +00:00
< ? php
2007-10-05 14:36:34 +00:00
/**
2005-12-10 23:20:21 +00:00
*
* @ package acp
* @ version $Id $
2007-10-05 14:36:34 +00:00
* @ copyright ( c ) 2005 phpBB Group
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
2005-12-10 23:20:21 +00:00
*
*/
2007-10-05 14:36:34 +00:00
/**
* @ ignore
*/
if ( ! defined ( 'IN_PHPBB' ))
{
exit ;
}
2005-12-10 23:20:21 +00:00
/**
* @ package acp
*/
class acp_prune
{
2006-02-18 13:54:12 +00:00
var $u_action ;
2005-12-10 23:20:21 +00:00
function main ( $id , $mode )
{
2006-06-06 20:53:46 +00:00
global $user , $phpEx , $phpbb_admin_path , $phpbb_root_path ;
2005-12-10 23:20:21 +00:00
$user -> add_lang ( 'acp/prune' );
2006-03-22 11:13:33 +00:00
include_once ( $phpbb_root_path . 'includes/functions_user.' . $phpEx );
2005-12-10 23:20:21 +00:00
switch ( $mode )
{
case 'forums' :
$this -> tpl_name = 'acp_prune_forums' ;
2006-05-21 16:54:19 +00:00
$this -> page_title = 'ACP_PRUNE_FORUMS' ;
2005-12-10 23:20:21 +00:00
$this -> prune_forums ( $id , $mode );
break ;
case 'users' :
$this -> tpl_name = 'acp_prune_users' ;
2006-05-21 16:54:19 +00:00
$this -> page_title = 'ACP_PRUNE_USERS' ;
2005-12-10 23:20:21 +00:00
$this -> prune_users ( $id , $mode );
break ;
}
}
/**
* Prune forums
*/
function prune_forums ( $id , $mode )
{
global $db , $user , $auth , $template , $cache ;
2006-06-06 20:53:46 +00:00
global $config , $phpbb_root_path , $phpbb_admin_path , $phpEx ;
2005-12-10 23:20:21 +00:00
2007-02-25 06:08:39 +00:00
$all_forums = request_var ( 'all_forums' , 0 );
2005-12-10 23:20:21 +00:00
$forum_id = request_var ( 'f' , array ( 0 ));
$submit = ( isset ( $_POST [ 'submit' ])) ? true : false ;
2007-02-25 06:08:39 +00:00
if ( $all_forums )
{
$sql = ' SELECT forum_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ' ;
$result = $db -> sql_query ( $sql );
$forum_id = array ();
while ( $row = $db -> sql_fetchrow ( $result ))
{
$forum_id [] = $row [ 'forum_id' ];
}
$db -> sql_freeresult ( $result );
}
2005-12-10 23:20:21 +00:00
if ( $submit )
{
2007-05-11 12:25:28 +00:00
if ( confirm_box ( true ))
2005-12-10 23:20:21 +00:00
{
2007-05-11 12:25:28 +00:00
$prune_posted = request_var ( 'prune_days' , 0 );
$prune_viewed = request_var ( 'prune_vieweddays' , 0 );
$prune_all = ( ! $prune_posted && ! $prune_viewed ) ? true : false ;
2005-12-10 23:20:21 +00:00
2007-05-11 12:25:28 +00:00
$prune_flags = 0 ;
$prune_flags += ( request_var ( 'prune_old_polls' , 0 )) ? 2 : 0 ;
$prune_flags += ( request_var ( 'prune_announce' , 0 )) ? 4 : 0 ;
$prune_flags += ( request_var ( 'prune_sticky' , 0 )) ? 8 : 0 ;
// Convert days to seconds for timestamp functions...
$prunedate_posted = time () - ( $prune_posted * 86400 );
$prunedate_viewed = time () - ( $prune_viewed * 86400 );
$template -> assign_vars ( array (
'S_PRUNED' => true )
);
$sql_forum = ( sizeof ( $forum_id )) ? ' AND ' . $db -> sql_in_set ( 'forum_id' , $forum_id ) : '' ;
// Get a list of forum's or the data for the forum that we are pruning.
2007-10-05 14:36:34 +00:00
$sql = ' SELECT forum_id , forum_name
2007-05-11 12:25:28 +00:00
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
2007-10-05 14:36:34 +00:00
$sql_forum
2007-05-11 12:25:28 +00:00
ORDER BY left_id ASC " ;
$result = $db -> sql_query ( $sql );
if ( $row = $db -> sql_fetchrow ( $result ))
2005-12-10 23:20:21 +00:00
{
2007-05-11 12:25:28 +00:00
$prune_ids = array ();
$p_result [ 'topics' ] = 0 ;
$p_result [ 'posts' ] = 0 ;
$log_data = '' ;
do
2005-12-10 23:20:21 +00:00
{
2007-05-11 12:25:28 +00:00
if ( ! $auth -> acl_get ( 'f_list' , $row [ 'forum_id' ]))
{
continue ;
}
2005-12-10 23:20:21 +00:00
2007-05-11 12:25:28 +00:00
if ( $prune_all )
2005-12-10 23:20:21 +00:00
{
2007-05-11 12:25:28 +00:00
$p_result = prune ( $row [ 'forum_id' ], 'posted' , time (), $prune_flags , false );
2005-12-10 23:20:21 +00:00
}
2007-05-11 12:25:28 +00:00
else
2005-12-10 23:20:21 +00:00
{
2007-05-11 12:25:28 +00:00
if ( $prune_posted )
{
$return = prune ( $row [ 'forum_id' ], 'posted' , $prunedate_posted , $prune_flags , false );
$p_result [ 'topics' ] += $return [ 'topics' ];
$p_result [ 'posts' ] += $return [ 'posts' ];
}
if ( $prune_viewed )
{
$return = prune ( $row [ 'forum_id' ], 'viewed' , $prunedate_viewed , $prune_flags , false );
$p_result [ 'topics' ] += $return [ 'topics' ];
$p_result [ 'posts' ] += $return [ 'posts' ];
}
2005-12-10 23:20:21 +00:00
}
2007-05-11 12:25:28 +00:00
$prune_ids [] = $row [ 'forum_id' ];
2005-12-10 23:20:21 +00:00
2007-05-11 12:25:28 +00:00
$template -> assign_block_vars ( 'pruned' , array (
'FORUM_NAME' => $row [ 'forum_name' ],
'NUM_TOPICS' => $p_result [ 'topics' ],
'NUM_POSTS' => $p_result [ 'posts' ])
);
$log_data .= (( $log_data != '' ) ? ', ' : '' ) . $row [ 'forum_name' ];
}
while ( $row = $db -> sql_fetchrow ( $result ));
// Sync all pruned forums at once
sync ( 'forum' , 'forum_id' , $prune_ids , true , true );
add_log ( 'admin' , 'LOG_PRUNE' , $log_data );
2005-12-10 23:20:21 +00:00
}
2007-05-11 12:25:28 +00:00
$db -> sql_freeresult ( $result );
2005-12-10 23:20:21 +00:00
2007-05-11 12:25:28 +00:00
return ;
}
else
{
confirm_box ( false , $user -> lang [ 'PRUNE_FORUM_CONFIRM' ], build_hidden_fields ( array (
'i' => $id ,
'mode' => $mode ,
'submit' => 1 ,
'all_forums' => $all_forums ,
'f' => $forum_id ,
'prune_days' => request_var ( 'prune_days' , 0 ),
'prune_vieweddays' => request_var ( 'prune_vieweddays' , 0 ),
'prune_old_polls' => request_var ( 'prune_old_polls' , 0 ),
'prune_announce' => request_var ( 'prune_announce' , 0 ),
'prune_sticky' => request_var ( 'prune_sticky' , 0 ),
)));
}
2005-12-10 23:20:21 +00:00
}
// If they haven't selected a forum for pruning yet then
// display a select box to use for pruning.
if ( ! sizeof ( $forum_id ))
{
$template -> assign_vars ( array (
'U_ACTION' => $this -> u_action ,
'S_SELECT_FORUM' => true ,
'S_FORUM_OPTIONS' => make_forum_select ( false , false , false ))
2006-06-16 16:54:51 +00:00
);
2005-12-10 23:20:21 +00:00
}
else
{
2007-10-05 14:36:34 +00:00
$sql = ' SELECT forum_id , forum_name
FROM ' . FORUMS_TABLE . '
2006-08-12 13:14:39 +00:00
WHERE ' . $db->sql_in_set(' forum_id ' , $forum_id );
2005-12-10 23:20:21 +00:00
$result = $db -> sql_query ( $sql );
2006-06-16 16:54:51 +00:00
$row = $db -> sql_fetchrow ( $result );
2005-12-10 23:20:21 +00:00
2006-06-16 16:54:51 +00:00
if ( ! $row )
2005-12-10 23:20:21 +00:00
{
2006-06-16 16:54:51 +00:00
$db -> sql_freeresult ( $result );
2006-08-28 15:50:33 +00:00
trigger_error ( $user -> lang [ 'NO_FORUM' ] . adm_back_link ( $this -> u_action ), E_USER_WARNING );
2005-12-10 23:20:21 +00:00
}
$forum_list = $s_hidden_fields = '' ;
do
{
$forum_list .= (( $forum_list != '' ) ? ', ' : '' ) . '<b>' . $row [ 'forum_name' ] . '</b>' ;
$s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row [ 'forum_id' ] . '" />' ;
}
while ( $row = $db -> sql_fetchrow ( $result ));
$db -> sql_freeresult ( $result );
$l_selected_forums = ( sizeof ( $forum_id ) == 1 ) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS' ;
$template -> assign_vars ( array (
'L_SELECTED_FORUMS' => $user -> lang [ $l_selected_forums ],
'U_ACTION' => $this -> u_action ,
'U_BACK' => $this -> u_action ,
'FORUM_LIST' => $forum_list ,
'S_HIDDEN_FIELDS' => $s_hidden_fields )
);
}
}
/**
* Prune users
*/
function prune_users ( $id , $mode )
{
global $db , $user , $auth , $template , $cache ;
2006-06-06 20:53:46 +00:00
global $config , $phpbb_root_path , $phpbb_admin_path , $phpEx ;
2005-12-10 23:20:21 +00:00
$user -> add_lang ( 'memberlist' );
$prune = ( isset ( $_POST [ 'prune' ])) ? true : false ;
if ( $prune )
{
2007-05-03 14:29:22 +00:00
$action = request_var ( 'action' , 'deactivate' );
2007-06-11 00:12:42 +00:00
$deleteposts = request_var ( 'deleteposts' , 0 );
2007-05-03 14:29:22 +00:00
2005-12-10 23:20:21 +00:00
if ( confirm_box ( true ))
{
$user_ids = $usernames = array ();
2010-05-25 10:52:01 -05:00
2007-05-03 14:29:22 +00:00
$this -> get_prune_users ( $user_ids , $usernames );
2006-03-22 11:13:33 +00:00
if ( sizeof ( $user_ids ))
2005-12-10 23:20:21 +00:00
{
2006-03-22 11:13:33 +00:00
if ( $action == 'deactivate' )
{
2006-10-03 18:35:59 +00:00
user_active_flip ( 'deactivate' , $user_ids );
2006-03-22 11:13:33 +00:00
$l_log = 'LOG_PRUNE_USER_DEAC' ;
}
else if ( $action == 'delete' )
2005-12-10 23:20:21 +00:00
{
if ( $deleteposts )
{
2010-05-25 10:52:01 -05:00
user_delete ( 'remove' , $user_ids );
2006-03-22 11:13:33 +00:00
2005-12-10 23:20:21 +00:00
$l_log = 'LOG_PRUNE_USER_DEL_DEL' ;
}
else
{
2010-05-17 12:12:00 -05:00
user_delete ( 'retain' , $user_ids , true );
2005-12-10 23:20:21 +00:00
$l_log = 'LOG_PRUNE_USER_DEL_ANON' ;
}
}
add_log ( 'admin' , $l_log , implode ( ', ' , $usernames ));
2007-02-23 16:39:03 +00:00
$msg = $user -> lang [ 'USER_' . strtoupper ( $action ) . '_SUCCESS' ];
}
else
{
$msg = $user -> lang [ 'USER_PRUNE_FAILURE' ];
2005-12-10 23:20:21 +00:00
}
2007-02-23 16:39:03 +00:00
trigger_error ( $msg . adm_back_link ( $this -> u_action ));
2005-12-10 23:20:21 +00:00
}
else
{
2007-05-03 14:29:22 +00:00
// We list the users which will be pruned...
$user_ids = $usernames = array ();
$this -> get_prune_users ( $user_ids , $usernames );
if ( ! sizeof ( $user_ids ))
{
trigger_error ( $user -> lang [ 'USER_PRUNE_FAILURE' ] . adm_back_link ( $this -> u_action ), E_USER_WARNING );
}
// Assign to template
foreach ( $user_ids as $user_id )
{
$template -> assign_block_vars ( 'users' , array (
'USERNAME' => $usernames [ $user_id ],
2010-05-25 10:52:01 -05:00
'USER_ID' => $user_id ,
2007-05-03 14:29:22 +00:00
'U_PROFILE' => append_sid ( $phpbb_root_path . 'memberlist.' . $phpEx , 'mode=viewprofile&u=' . $user_id ),
'U_USER_ADMIN' => ( $auth -> acl_get ( 'a_user' )) ? append_sid ( " { $phpbb_admin_path } index. $phpEx " , 'i=users&mode=overview&u=' . $user_id , true , $user -> session_id ) : '' ,
));
}
$template -> assign_vars ( array (
'S_DEACTIVATE' => ( $action == 'deactivate' ) ? true : false ,
'S_DELETE' => ( $action == 'delete' ) ? true : false ,
));
2005-12-10 23:20:21 +00:00
confirm_box ( false , $user -> lang [ 'CONFIRM_OPERATION' ], build_hidden_fields ( array (
'i' => $id ,
'mode' => $mode ,
'prune' => 1 ,
'deleteposts' => request_var ( 'deleteposts' , 0 ),
'action' => request_var ( 'action' , '' ),
2007-05-03 14:29:22 +00:00
)), 'confirm_body_prune.html' );
2005-12-10 23:20:21 +00:00
}
}
$find_count = array ( 'lt' => $user -> lang [ 'LESS_THAN' ], 'eq' => $user -> lang [ 'EQUAL_TO' ], 'gt' => $user -> lang [ 'MORE_THAN' ]);
$s_find_count = '' ;
foreach ( $find_count as $key => $value )
{
$selected = ( $key == 'eq' ) ? ' selected="selected"' : '' ;
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>' ;
}
$find_time = array ( 'lt' => $user -> lang [ 'BEFORE' ], 'gt' => $user -> lang [ 'AFTER' ]);
$s_find_active_time = '' ;
foreach ( $find_time as $key => $value )
{
$s_find_active_time .= '<option value="' . $key . '">' . $value . '</option>' ;
}
2011-12-12 20:17:31 -06:00
$s_group_list = '' ;
2010-05-25 10:52:01 -05:00
$sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . '
WHERE group_type <> ' . GROUP_SPECIAL . '
ORDER BY group_name ASC ' ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
{
$s_group_list .= '<option value="' . $row [ 'group_id' ] . '">' . $row [ 'group_name' ] . '</select>' ;
}
2005-12-10 23:20:21 +00:00
$template -> assign_vars ( array (
'U_ACTION' => $this -> u_action ,
'S_ACTIVE_OPTIONS' => $s_find_active_time ,
2010-05-25 10:52:01 -05:00
'S_GROUP_LIST' => $s_group_list ,
2005-12-10 23:20:21 +00:00
'S_COUNT_OPTIONS' => $s_find_count ,
2007-09-22 18:31:50 +00:00
'U_FIND_USERNAME' => append_sid ( " { $phpbb_root_path } memberlist. $phpEx " , 'mode=searchuser&form=acp_prune&field=users' ),
));
2005-12-10 23:20:21 +00:00
}
2007-05-03 14:29:22 +00:00
/**
* Get user_ids / usernames from those being pruned
*/
function get_prune_users ( & $user_ids , & $usernames )
{
global $user , $db ;
2010-05-25 10:52:01 -05:00
$users_by_name = request_var ( 'users' , '' , true );
$users_by_id = request_var ( 'user_ids' , array ( 0 ));
2011-12-12 20:17:31 -06:00
$group_id = request_var ( 'group_id' , 0 );
$posts_on_queue = request_var ( 'posts_on_queue' , 0 );
2010-05-25 10:52:01 -05:00
if ( $users_by_name )
2007-05-03 14:29:22 +00:00
{
2010-05-25 10:52:01 -05:00
$users = explode ( " \n " , $users_by_name );
2007-05-03 14:29:22 +00:00
$where_sql = ' AND ' . $db -> sql_in_set ( 'username_clean' , array_map ( 'utf8_clean_string' , $users ));
}
2010-05-25 10:52:01 -05:00
else if ( ! empty ( $users_by_id ))
{
$user_ids = $users_by_id ;
user_get_id_name ( $user_ids , $usernames );
$where_sql = ' AND ' . $db -> sql_in_set ( 'user_id' , $user_ids );
}
2007-05-03 14:29:22 +00:00
else
{
2010-05-25 10:52:01 -05:00
$username = request_var ( 'username' , '' , true );
2007-05-03 14:29:22 +00:00
$email = request_var ( 'email' , '' );
2010-05-25 10:52:01 -05:00
$website = request_var ( 'website' , '' );
2007-05-03 14:29:22 +00:00
$active_select = request_var ( 'active_select' , 'lt' );
$count_select = request_var ( 'count_select' , 'eq' );
2010-05-25 10:52:01 -05:00
$queue_select = request_var ( 'queue_select' , 'gt' );
$joined_before = request_var ( 'joined_before' , '' );
$joined_after = request_var ( 'joined_after' , '' );
2007-05-03 14:29:22 +00:00
$active = request_var ( 'active' , '' );
2010-05-25 10:52:01 -05:00
$count = request_var ( 'count' , 0 );
2007-05-03 14:29:22 +00:00
$active = ( $active ) ? explode ( '-' , $active ) : array ();
2010-05-25 10:52:01 -05:00
$joined_before = ( $joined_before ) ? explode ( '-' , $joined_before ) : array ();
$joined_after = ( $joined_after ) ? explode ( '-' , $joined_after ) : array ();
2007-05-03 14:29:22 +00:00
2010-05-25 10:52:01 -05:00
// calculate the conditions required by the join time criteria
$joined_sql = '' ;
if ( ! empty ( $joined_before ) && ! empty ( $joined_after ))
2007-05-03 14:29:22 +00:00
{
2010-05-25 10:52:01 -05:00
// if the two entered dates are equal, we need to adjust
// so that our time range is a full day instead of 1 second
if ( $joined_after == $joined_before )
{
$joined_after [ 2 ] += 1 ; //$joined_after[2]++;
}
$joined_sql = ' AND user_regdate BETWEEN ' . gmmktime ( 0 , 0 , 0 , ( int ) $joined_after [ 1 ], ( int ) $joined_after [ 2 ], ( int ) $joined_after [ 0 ]) . ' AND ' . gmmktime ( 0 , 0 , 0 , ( int ) $joined_before [ 1 ], ( int ) $joined_before [ 2 ], ( int ) $joined_before [ 0 ]);
}
else if ( empty ( $joined_before ) && ! empty ( $joined_after ))
{
$joined_sql = ' AND user_regdate > ' . gmmktime ( 0 , 0 , 0 , ( int ) $joined_after [ 1 ], ( int ) $joined_after [ 2 ], ( int ) $joined_after [ 0 ]);
}
else if ( empty ( $joined_after ) && ! empty ( $joined_before ))
{
2011-12-12 20:17:31 -06:00
$joined_sql = ' AND user_regdate < ' . gmmktime ( 0 , 0 , 0 , ( int ) $joined_before [ 1 ], ( int ) $joined_before [ 2 ], ( int ) $joined_before [ 0 ]);
2007-05-03 14:29:22 +00:00
}
2010-05-25 10:52:01 -05:00
// implicit else when both arrays are empty do nothing
2007-05-03 14:29:22 +00:00
2010-05-25 10:52:01 -05:00
if (( sizeof ( $active ) && sizeof ( $active ) != 3 ) || ( sizeof ( $joined_before ) && sizeof ( $joined_before ) != 3 ) || ( sizeof ( $joined_after ) && sizeof ( $joined_after ) != 3 ))
{
trigger_error ( $user -> lang [ 'WRONG_ACTIVE_JOINED_DATE' ] . adm_back_link ( $this -> u_action ), E_USER_WARNING );
}
2007-05-03 14:29:22 +00:00
$key_match = array ( 'lt' => '<' , 'gt' => '>' , 'eq' => '=' );
$sort_by_types = array ( 'username' , 'user_email' , 'user_posts' , 'user_regdate' , 'user_lastvisit' );
$where_sql = '' ;
2007-06-24 12:49:13 +00:00
$where_sql .= ( $username ) ? ' AND username_clean ' . $db -> sql_like_expression ( str_replace ( '*' , $db -> any_char , utf8_clean_string ( $username ))) : '' ;
$where_sql .= ( $email ) ? ' AND user_email ' . $db -> sql_like_expression ( str_replace ( '*' , $db -> any_char , $email )) . ' ' : '' ;
2010-05-25 10:52:01 -05:00
$where_sql .= ( $website ) ? ' AND user_website ' . $db -> sql_like_expression ( str_replace ( '*' , $db -> any_char , $website )) . ' ' : '' ;
$where_sql .= $joined_sql ;
$where_sql .= ( $count ) ? " AND user_posts " . $key_match [ $count_select ] . ' ' . ( int ) $count . ' ' : '' ;
2008-03-21 10:47:02 +00:00
2009-07-14 12:02:11 +00:00
// First handle pruning of users who never logged in, last active date is 0000-00-00
if ( sizeof ( $active ) && ( int ) $active [ 0 ] == 0 && ( int ) $active [ 1 ] == 0 && ( int ) $active [ 2 ] == 0 )
{
$where_sql .= ' AND user_lastvisit = 0' ;
}
else if ( sizeof ( $active ) && $active_select != 'lt' )
2008-03-21 10:47:02 +00:00
{
$where_sql .= ' AND user_lastvisit ' . $key_match [ $active_select ] . ' ' . gmmktime ( 0 , 0 , 0 , ( int ) $active [ 1 ], ( int ) $active [ 2 ], ( int ) $active [ 0 ]);
}
else if ( sizeof ( $active ))
{
$where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime ( 0 , 0 , 0 , ( int ) $active [ 1 ], ( int ) $active [ 2 ], ( int ) $active [ 0 ]) . ')' ;
}
2007-05-03 14:29:22 +00:00
}
// Protect the admin, do not prune if no options are given...
if ( ! $where_sql )
{
return ;
}
// Get bot ids
2007-10-05 14:36:34 +00:00
$sql = ' SELECT user_id
2007-05-03 14:29:22 +00:00
FROM ' . BOTS_TABLE ;
$result = $db -> sql_query ( $sql );
$bot_ids = array ();
while ( $row = $db -> sql_fetchrow ( $result ))
{
$bot_ids [] = $row [ 'user_id' ];
}
$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 ))
{
// 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 );
2010-05-25 10:52:01 -05:00
if ( $group_id )
{
$sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . '
WHERE group_id = ' . (int) $group_id . '
AND user_pending = 0
AND ' . $db->sql_in_set(' user_id ' , $user_ids , false , true );
$result = $db -> sql_query ( $sql );
// we're performing an intersection operation, so all the relevant users
// come from this most recent query (which was limited to the results of the
// previous query)
$user_ids = $usernames = array ();
while ( $row = $db -> sql_fetchrow ( $result ))
{
$user_ids [] = $row [ 'poster_id' ];
}
// only get usernames if they are needed (not part of some later query)
if ( ! $posts_on_queue )
{
// this is an additional query aginst the users table
user_get_id_name ( $user_ids , $usernames );
}
}
if ( $posts_on_queue )
{
$sql = 'SELECT poster_id, COUNT(post_id) AS queue_posts FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set(' poster_id ' , $user_ids , false , true ) .
' GROUP BY poster_id
HAVING queue_posts ' . $key_match[$queue_select] . ' ' . $posts_on_queue ;
$result = $db -> sql_query ( $result );
// same intersection logic as the above group ID portion
$user_ids = $usernames = array ();
while ( $row = $db -> sql_fetchrow ( $result ))
{
$user_ids [] = $row [ 'poster_id' ];
}
// do an additional query to get the correct set of usernames
user_get_id_name ( $user_ids , $usernames );
}
2007-05-03 14:29:22 +00:00
}
2005-12-10 23:20:21 +00:00
}