/** * Calcs the shared country rank. Multiple users can share one rank in theory. Return -1 on no country. * @param GWF_User $user * @return int */ public static function calcCountryRank(GWF_User $user) { if ('0' === ($cid = $user->getVar('user_countryid'))) { return -1; } $deleted = GWF_User::DELETED; $score = $user->getVar('user_level'); return $user->countRows("user_options&0x10000000=0 AND user_options&{$deleted}=0 AND user_level>{$score} AND user_countryid={$cid}") + 1; }