if (!empty($showgroups) AND $vbulletin->options['credits_numrich'])
{
switch ($vbulletin->options['credits_display'])
{
case 'hand':
$sqlsort = 'credits';
break;
case 'bank':
$sqlsort = 'credits_saved';
break;
case 'both':
$sqlsort = '(credits + credits_saved)';
break;
}
$show['topx'] = true;
$topusers = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "user WHERE usergroupid IN (" . implode(', ', $showgroups) . ") ORDER BY $sqlsort DESC LIMIT " . $vbulletin->options['credits_numrich']);
while ($userinfo = $db->fetch_array($topusers))
{
cache_permissions($userinfo, false);
fetch_musername($userinfo);
$userinfo = array_merge($userinfo , convert_bits_to_array($userinfo['options'] , $vbulletin->bf_misc_useroptions), convert_bits_to_array($userinfo['adminoptions'] , $vbulletin->bf_misc_adminoptions));
$userinfo['datejoined'] = vbdate($vbulletin->options['dateformat'], $userinfo['joindate'], true);
$show['emaillink'] = ($userinfo['showemail'] AND $vbulletin->options['displayemails'] AND (!$vbulletin->options['secureemail'] OR ($vbulletin->options['secureemail'] AND $vbulletin->options['enableemail'])) AND $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canemailmember']);
$show['pmlink'] = ($vbulletin->options['enablepms'] AND $vbulletin->userinfo['permissions']['pmquota'] AND ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] OR ($userinfo['receivepm'] AND $userinfo['permissions']['pmquota'] AND (!$userinfo['receivepmbuddies'] OR can_moderate() OR strpos(" $userinfo[buddylist] ", ' ' . $vbulletin->userinfo['userid'] . ' ') !== false))));
$special = ($userinfo['userid'] == $vbulletin->userinfo['userid'] OR $vbulletin->bf_ugp['creditpermissions']['credit_special'] & $creditperms['creditpermissions']);
$displayamount = ($vbulletin->options['credits_display'] != 'bank') * $userinfo['credits'] + ($vbulletin->options['credits_display'] != 'hand') * $userinfo['credits_saved'];
$userinfo['credits'] = ( (!($vbulletin->bf_ugp['creditpermissions']['credit_locked'] & $creditperms['creditpermissions']) AND ((!($vbulletin->bf_ugp['creditpermissions']['credit_hidden'] & $vbulletin->usergroupcache[$userinfo['usergroupid']]['creditpermissions'])) OR $special) AND ($vbulletin->options['credits_public'] == 'all' OR ($vbulletin->options['credits_public'] == 'some' AND $special))) ? vb_number_format(( ($vbulletin->options['credits_neghandle'] != 'normal' AND $displayamount < 0) ? 0 : $displayamount ), $vbulletin->options['credits_decimals']) : $vbphrase['n_a'] );
($hook = vBulletinHook::fetch_hook('credits_panel_rich')) ? eval($hook) : false;
eval('$topentries .= "' . fetch_template('credits_toprow') . '";');
}
$db->free_result($topusers);
}