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,19 +2075,20 @@ class ItemListFilter extends Filter
else else
return [0]; return [0];
case 90: // avgbuyout [op] [int] case 90: // avgbuyout [op] [int]
if (!DB::isConnectable(DB_CHARACTERS))
return [1];
if (!$this->isSaneNumeric($cr[2]) || !$this->int2Op($cr[1])) if (!$this->isSaneNumeric($cr[2]) || !$this->int2Op($cr[1]))
break; break;
/* no no no .. for each realm! foreach (Util::getRealms() as $rId => $__)
// 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])) // todo: do something sensible..
return ['i.id', array_keys($_)]; // // todo (med): get the avgbuyout into the listview
else // 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 [0]; // return ['i.id', array_keys($_)];
*/ // else
// return [0];
return [1];
}
return [0]; return [0];
case 65: // avgmoney [op] [int] case 65: // avgmoney [op] [int]
if (!$this->isSaneNumeric($cr[2]) || !$this->int2Op($cr[1])) if (!$this->isSaneNumeric($cr[2]) || !$this->int2Op($cr[1]))

View File

@@ -1601,7 +1601,17 @@ class Util
public static function getRealms() public static function getRealms()
{ {
if (DB::isConnectable(DB_AUTH) && !self::$realms) 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); 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; return self::$realms;
} }

View File

@@ -103,14 +103,9 @@ class AchievementPage extends GenericPage
if ($this->subject->getField('flags') & 0x100 && DB::isConnectable(DB_AUTH)) if ($this->subject->getField('flags') & 0x100 && DB::isConnectable(DB_AUTH))
{ {
$avlb = []; $avlb = [];
foreach (DB::Auth()->selectCol('SELECT id AS ARRAY_KEY, name FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_BUILD) AS $rId => $name) foreach (Util::getRealms() AS $rId => $rData)
{
if (!DB::isConnectable(DB_CHARACTERS . $rId))
continue;
if (!DB::Characters($rId)->selectCell('SELECT 1 FROM character_achievement WHERE achievement = ?d LIMIT 1', $this->typeId)) 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) if ($avlb)
$infobox[] = Lang::achievement('rfAvailable').implode(', ', $avlb); $infobox[] = Lang::achievement('rfAvailable').implode(', ', $avlb);