Quote:
Originally Posted by kh99
Well, I don't know if it's the best way, but if you look at admin/user.php in the section that starts with "if ($_REQUEST['do'] == 'find')", it's doing something similar in that there are a lot of possible fields you can fill in to search by. It calls fetch_user_search_sql() which is in adminfunctions_user.php, but it just pretty much goes through checkng all the options and adding to the sql as necessary.
|
Thanks for the idea! That worked nicely.
Here's a short exerp of what I did:
PHP Code:
if ($_REQUEST['do'] == 'show')
{
$graceperiod = $vbulletin->input->clean_gpc( 'p', 'graceperiod', TYPE_STR);
$emailfreq = $vbulletin->input->clean_gpc( 'r', 'emailfreq', TYPE_STR );
$temp_grouplist = $vbulletin->input->clean_gpc( 'r', 'membergroups', TYPE_ARRAY);
$temp_grouplist = implode(',',$temp_grouplist);
$usergroups = str_replace(",","','", trim($temp_grouplist));
$excludeduserids = str_replace(",","','", trim($vbulletin->input->clean_gpc( 'r', 'excludedUserIds', TYPE_STR)));
$canreceivemailfromadmin = $vbulletin->input->clean_gpc( 'r', 'canreceivemailfromadmin', TYPE_BOOL );
$includeoptouts = $vbulletin->input->clean_gpc( 'r', 'includeoptouts', TYPE_BOOL );
$vbulletin->input->clean_array_gpc('r', array(
'perpage' => TYPE_INT,
'page' => TYPE_INT
));
if (empty($vbulletin->GPC['perpage']))
{
$vbulletin->GPC['perpage'] = 15;
}
$condition = "1=1 ";
$condition .= iif(!empty($graceperiod), " AND TIMESTAMPDIFF(DAY, FROM_UNIXTIME(lastactivity), FROM_UNIXTIME(UNIX_TIMESTAMP())) >= ". $graceperiod . " ");
$condition .= iif(!empty($emailfreq), " AND TIMESTAMPDIFF(DAY, FROM_UNIXTIME(rmEmailDate), FROM_UNIXTIME(UNIX_TIMESTAMP())) >= ". $emailfreq . " ");
$condition .= iif(!empty($usergroups), " AND usergroupid IN ('" . $usergroups . "') ");
$condition .= iif(!empty($excludeduserids), " AND userid NOT IN ('" . $excludeduserids . "') ");
$condition .= iif($canreceivemailfromadmin, "AND options & 16 ");
$condition .= iif($includeoptouts, " AND rmoptout = 1 ");
EDIT: One thing I'm running into now though is that if there is more than one page, my form values don't follow through from page to page and I loose my condition for my query.