Util/Realms

* check for accessibility
 * use for achievements/realm firsts
This commit is contained in:
Sarjuuk
2015-08-30 13:47:42 +02:00
parent 645894fdbf
commit 58babe24fe
3 changed files with 24 additions and 18 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);