mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Profiler/Realms
* skip out of List construction if realms are empty or do not match preselection * also prefilter Guilds and Prolfiles Lists for server or region (unless custom profiles) * discard ProfileList entries for inaccessible realms
This commit is contained in:
@@ -133,7 +133,7 @@ class RemoteArenaTeamList extends ArenaTeamList
|
||||
// select DB by realm
|
||||
if (!$this->selectRealms($miscData))
|
||||
{
|
||||
trigger_error('no access to auth-db or table realmlist is empty', E_USER_WARNING);
|
||||
trigger_error('RemoteArenaTeamList::__construct - cannot access any realm.', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -342,20 +342,25 @@ class LocalArenaTeamList extends ArenaTeamList
|
||||
$realms = Profiler::getRealms();
|
||||
|
||||
// graft realm selection from miscData onto conditions
|
||||
$realmIds = [];
|
||||
if (isset($miscData['sv']))
|
||||
$realmIds = array_merge($realmIds, array_keys(array_filter($realms, fn($x) => Profiler::urlize($x['name']) == Profiler::urlize($miscData['sv']))));
|
||||
$realms = array_filter($realms, fn($x) => Profiler::urlize($x['name']) == Profiler::urlize($miscData['sv']));
|
||||
|
||||
if (isset($miscData['rg']))
|
||||
$realmIds = array_merge($realmIds, array_keys(array_filter($realms, fn($x) => $x['region'] == $miscData['rg'])));
|
||||
$realms = array_filter($realms, fn($x) => $x['region'] == $miscData['rg']);
|
||||
|
||||
if ($realmIds && $conditions)
|
||||
if (!$realms)
|
||||
{
|
||||
trigger_error('LocalArenaTeamList::__construct - cannot access any realm.', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($conditions)
|
||||
{
|
||||
array_unshift($conditions, 'AND');
|
||||
$conditions = ['AND', ['realm', $realmIds], $conditions];
|
||||
$conditions = ['AND', ['realm', array_keys($realms)], $conditions];
|
||||
}
|
||||
else if ($realmIds)
|
||||
$conditions = [['realm', $realmIds]];
|
||||
else
|
||||
$conditions = [['realm', array_keys($realms)]];
|
||||
|
||||
parent::__construct($conditions, $miscData);
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class RemoteGuildList extends GuildList
|
||||
// select DB by realm
|
||||
if (!$this->selectRealms($miscData))
|
||||
{
|
||||
trigger_error('no access to auth-db or table realmlist is empty', E_USER_WARNING);
|
||||
trigger_error('RemoteGuildList::__construct - cannot access any realm.', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -280,13 +280,34 @@ class LocalGuildList extends GuildList
|
||||
|
||||
public function __construct(array $conditions = [], array $miscData = [])
|
||||
{
|
||||
$realms = Profiler::getRealms();
|
||||
|
||||
// graft realm selection from miscData onto conditions
|
||||
if (isset($miscData['sv']))
|
||||
$realms = array_filter($realms, fn($x) => Profiler::urlize($x['name']) == Profiler::urlize($miscData['sv']));
|
||||
|
||||
if (isset($miscData['rg']))
|
||||
$realms = array_filter($realms, fn($x) => $x['region'] == $miscData['rg']);
|
||||
|
||||
if (!$realms)
|
||||
{
|
||||
trigger_error('LocalGuildList::__construct - cannot access any realm.', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($conditions)
|
||||
{
|
||||
array_unshift($conditions, 'AND');
|
||||
$conditions = ['AND', ['realm', array_keys($realms)], $conditions];
|
||||
}
|
||||
else
|
||||
$conditions = [['realm', array_keys($realms)]];
|
||||
|
||||
parent::__construct($conditions, $miscData);
|
||||
|
||||
if ($this->error)
|
||||
return;
|
||||
|
||||
$realms = Profiler::getRealms();
|
||||
|
||||
foreach ($this->iterate() as $id => &$curTpl)
|
||||
{
|
||||
if ($curTpl['realm'] && !isset($realms[$curTpl['realm']]))
|
||||
|
||||
@@ -520,7 +520,7 @@ class RemoteProfileList extends ProfileList
|
||||
// select DB by realm
|
||||
if (!$this->selectRealms($miscData))
|
||||
{
|
||||
trigger_error('no access to auth-db or table realmlist is empty', E_USER_WARNING);
|
||||
trigger_error('RemoteProfileList::__construct - cannot access any realm.', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -738,25 +738,42 @@ class LocalProfileList extends ProfileList
|
||||
|
||||
public function __construct(array $conditions = [], array $miscData = [])
|
||||
{
|
||||
$realms = Profiler::getRealms();
|
||||
|
||||
// graft realm selection from miscData onto conditions
|
||||
$realmIds = [];
|
||||
if (isset($miscData['sv']))
|
||||
$realmIds = array_keys(array_filter($realms, fn($x) => Profiler::urlize($x['name']) == Profiler::urlize($miscData['sv'])));
|
||||
|
||||
if (isset($miscData['rg']))
|
||||
$realmIds = array_merge($realmIds, array_keys(array_filter($realms, fn($x) => $x['region'] == $miscData['rg'])));
|
||||
|
||||
if ($conditions && $realmIds)
|
||||
{
|
||||
array_unshift($conditions, 'AND');
|
||||
$conditions = ['AND', ['realm', $realmIds], $conditions];
|
||||
}
|
||||
else if ($realmIds)
|
||||
$conditions = [['realm', $realmIds]];
|
||||
|
||||
parent::__construct($conditions, $miscData);
|
||||
|
||||
if ($this->error)
|
||||
return;
|
||||
|
||||
$realms = Profiler::getRealms();
|
||||
|
||||
foreach ($this->iterate() as $id => &$curTpl)
|
||||
{
|
||||
if ($curTpl['realm'] && !isset($realms[$curTpl['realm']]))
|
||||
if (!$curTpl['realm']) // custom profile w/o realminfo
|
||||
continue;
|
||||
|
||||
if (isset($realms[$curTpl['realm']]))
|
||||
if (!isset($realms[$curTpl['realm']]))
|
||||
{
|
||||
$curTpl['realmName'] = $realms[$curTpl['realm']]['name'];
|
||||
$curTpl['region'] = $realms[$curTpl['realm']]['region'];
|
||||
unset($this->templates[$id]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// battlegroup
|
||||
$curTpl['realmName'] = $realms[$curTpl['realm']]['name'];
|
||||
$curTpl['region'] = $realms[$curTpl['realm']]['region'];
|
||||
$curTpl['battlegroup'] = Cfg::get('BATTLEGROUP');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user