diff --git a/includes/types/item.class.php b/includes/types/item.class.php index f45668c6..a6488a3d 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -2075,20 +2075,21 @@ class ItemListFilter extends Filter else return [0]; case 90: // avgbuyout [op] [int] - if (!DB::isConnectable(DB_CHARACTERS)) - return [1]; - if (!$this->isSaneNumeric($cr[2]) || !$this->int2Op($cr[1])) break; - /* no no no .. for each realm! - // todo (med): get the avgbuyout into the listview - if ($_ = DB::Characters()->select('SELECT ii.itemEntry AS ARRAY_KEY, AVG(ah.buyoutprice / ii.count) AS buyout FROM auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid GROUP BY ii.itemEntry HAVING avgbuyout '.$cr[1].' ?f', $c[1])) - return ['i.id', array_keys($_)]; - else - return [0]; - */ - return [0]; + foreach (Util::getRealms() as $rId => $__) + { + // todo: do something sensible.. + // // todo (med): get the avgbuyout into the listview + // if ($_ = DB::Characters()->select('SELECT ii.itemEntry AS ARRAY_KEY, AVG(ah.buyoutprice / ii.count) AS buyout FROM auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid GROUP BY ii.itemEntry HAVING avgbuyout '.$cr[1].' ?f', $c[1])) + // return ['i.id', array_keys($_)]; + // else + // return [0]; + return [1]; + } + + return [0]; case 65: // avgmoney [op] [int] if (!$this->isSaneNumeric($cr[2]) || !$this->int2Op($cr[1])) break; diff --git a/includes/utilities.php b/includes/utilities.php index b65a4eec..5b2b2370 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1601,7 +1601,17 @@ class Util public static function getRealms() { if (DB::isConnectable(DB_AUTH) && !self::$realms) + { self::$realms = DB::Auth()->select('SELECT id AS ARRAY_KEY, name, IF(timezone IN (8, 9, 10, 11, 12), "eu", "us") AS region FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_BUILD); + foreach (self::$realms as $rId => $rData) + { + if (DB::isConnectable(DB_CHARACTERS . $rId)) + continue; + + unset(self::$realms[$rId]); + trigger_error('Realm #'.$rId.' ('.$rData['name'].') has no connection info set.', E_USER_NOTICE); + } + } return self::$realms; } diff --git a/pages/achievement.php b/pages/achievement.php index d5bc2efd..6d870f89 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -103,14 +103,9 @@ class AchievementPage extends GenericPage if ($this->subject->getField('flags') & 0x100 && DB::isConnectable(DB_AUTH)) { $avlb = []; - foreach (DB::Auth()->selectCol('SELECT id AS ARRAY_KEY, name FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_BUILD) AS $rId => $name) - { - if (!DB::isConnectable(DB_CHARACTERS . $rId)) - continue; - + foreach (Util::getRealms() AS $rId => $rData) if (!DB::Characters($rId)->selectCell('SELECT 1 FROM character_achievement WHERE achievement = ?d LIMIT 1', $this->typeId)) - $avlb[] = Util::ucWords($name); - } + $avlb[] = Util::ucWords($rData['name']); if ($avlb) $infobox[] = Lang::achievement('rfAvailable').implode(', ', $avlb);