battles/classes/Battles/Admin/Clan.php
Ivor Barhansky 0398425205 Code smell.
2022-12-17 03:03:56 +02:00

50 lines
1.4 KiB
PHP

<?php
namespace Battles\Admin;
use Battles\Bank;
use Battles\Database\Db;
use Battles\GameConfigs;
use Battles\User;
class Clan
{
public static function getUnapprovedList(): string
{
$list = '';
$rows = Db::getInstance()->ofetchAll('select * from clans where status = 0');
foreach ($rows as $row) {
$id = $row->owner_id;
$login = User::getInstance($id)->getLogin();
$full = $row->full_name;
$short = $row->short_name;
$info = nl2br($row->info);
$list .= <<<UNREGCLANLIST
<div>
<fieldset style="display: inline;">
<legend>$full [$short]</legend>
Глава клана: <span class="abils">$login</span><br>
Описание:<div class="abils">$info</div>
<BR>
<button onclick="location.href='?regclan=$id'">Зарегистрировать</button>
<button onclick="location.href='?remclan=$id'">Отказать</button>
</fieldset>
</div>
UNREGCLANLIST;
}
return $list;
}
public static function allowRegister($id)
{
Db::getInstance()->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
}
public static function disallowRegister($id)
{
$bank = new Bank($id);
Db::getInstance()->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
$bank->modify(GameConfigs::CLAN['clan_register_cost']);
}
}