Админка: класс регистрации кланов.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?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::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user