Now I have optimize the query for get color groups (with secondary group selected).
PHP Code:
function fetch_thanks($postid = 0, $postids = '', $fetch_again = false)
{
global $vbulletin;
static $cache, $act;
($hook = vBulletinHook::fetch_hook('post_thanks_function_fetch_thanks_start')) ? eval($hook) : false;
if ((!($cache) && !($act)) || ($fetch_again))
{
$cache = array();
if ($postids)
{
$post_ids = "0$postids";
}
else
{
$post_ids = $postid;
}
$thanks = $vbulletin->db->query_read("SELECT ps.*, u.username,u.usergroupid,u.displaygroupid FROM " .TABLE_PREFIX. "post_thanks AS ps INNER JOIN " .TABLE_PREFIX. "user AS u ON (u.userid = ps.userid) WHERE ps.postid IN (" . $post_ids . ") ORDER BY ps.username ASC");
while ($thank = $vbulletin->db->fetch_array($thanks))
{
$cache[$thank['postid']][$thank['userid']]['userid'] = $thank['userid'];
//$cache[$thank['postid']][$thank['userid']]['username'] = $thank['username'];
// Get vBulletin User Group ID
$cache[$thank['postid']][$thank['userid']]['username'] = fetch_musername($thank);
$cache[$thank['postid']][$thank['userid']]['date'] = $thank['date'];
$cache[$thank['postid']][$thank['userid']]['postid'] = $thank['postid'];
}
}
($hook = vBulletinHook::fetch_hook('post_thanks_function_fetch_thanks_end')) ? eval($hook) : false;
$act = true;
return $cache[$postid];
}
Thanks for hack