From 23c1df72aa50a095d8dd04f711aa313031c70143 Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 19 Oct 2017 10:41:39 +0200 Subject: [PATCH] * fixed when ban expires is unlimited * moved Banished code to twig --- system/pages/characters.php | 12 ++++++------ system/templates/characters.html.twig | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/system/pages/characters.php b/system/pages/characters.php index ae17bd8d..10abcf9e 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -351,16 +351,16 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil // check if account has been banned $bannedUntil = ''; $banned = array(); - if (tableExist('account_bans')) - $banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and `expires_at` > ' . time()); + if(tableExist('account_bans')) + $banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and (`expires_at` > ' . time() . ' OR `expires_at` = -1);'); else if (tableExist('bans')) { if (fieldExist('expires', 'bans')) - $banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and `expires` > ' . time()); + $banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and (`expires` > ' . time() . ' OR `expires` = -1);'); else - $banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and `time` > ' . time()); + $banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and (`time` > ' . time() . ' OR `time` = -1);'); } - foreach ($banned as $ban) { - $bannedUntil = ' [Banished ' . ($ban['expires'] == "-1" ? 'forever' : 'until ' . date("d F Y, h:s", $ban['expires'])) . ']'; + foreach($banned as $ban) { + $bannedUntil = $ban['expires']; } $account_players = $account->getPlayersList(); diff --git a/system/templates/characters.html.twig b/system/templates/characters.html.twig index c09b37b5..051c114f 100644 --- a/system/templates/characters.html.twig +++ b/system/templates/characters.html.twig @@ -329,7 +329,13 @@ {% set rows = rows + 1 %} Created: - {{ account.getCustomField("created")|date("j F Y, g:i a") ~ bannedUntil|raw }} + {{ account.getCustomField("created")|date("j F Y, g:i a") }} + {% if bannedUntil matches '/^\\d+$/' or bannedUntil == '-1' %} + [Banished {% if bannedUntil == '-1' %}forever{% else %}until {{ bannedUntil|date('d F Y, h:s') }}{% endif %}] + {% else %} + {{ bannedUntil|raw }} + {% endif %} + {{ hook(constant('HOOK_CHARACTERS_AFTER_ACCOUNT')) }}