mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-13 17:24:54 +02:00
Don't count deleted players (patched from develop)
This commit is contained in:
@@ -138,7 +138,7 @@ class CreateCharacter
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$number_of_players_on_account = $account->getPlayersList()->count();
|
||||
$number_of_players_on_account = $account->getPlayersList(false)->count();
|
||||
if($number_of_players_on_account >= config('characters_per_account'))
|
||||
$errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.config('characters_per_account').')</b>!';
|
||||
}
|
||||
|
@@ -733,7 +733,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @return OTS_Players_List List of players from current account.
|
||||
* @throws E_OTS_NotLoaded If account is not loaded.
|
||||
*/
|
||||
public function getPlayersList()
|
||||
public function getPlayersList($withDeleted = true)
|
||||
{
|
||||
if( !isset($this->data['id']) )
|
||||
{
|
||||
@@ -744,6 +744,15 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$filter = new OTS_SQLFilter();
|
||||
$filter->compareField('account_id', (int) $this->data['id']);
|
||||
|
||||
if(!$withDeleted) {
|
||||
global $db;
|
||||
if($db->hasColumn('players', 'deletion')) {
|
||||
$filter->compareField('deletion', 0);
|
||||
} else {
|
||||
$filter->compareField('deleted', 0);
|
||||
}
|
||||
}
|
||||
|
||||
// creates list object
|
||||
$list = new OTS_Players_List();
|
||||
$list->setFilter($filter);
|
||||
|
Reference in New Issue
Block a user