Админка: класс регистрации кланов.
This commit is contained in:
parent
5b29d5b593
commit
197e489e0e
@ -6,11 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
require_once '../functions.php';
|
require_once '../functions.php';
|
||||||
|
|
||||||
use Battles\Bank;
|
use Battles\Admin\Clan;
|
||||||
use Battles\Database\Db;
|
use Battles\Database\Db;
|
||||||
use Battles\GameConfigs;
|
|
||||||
use Battles\Moderation;
|
use Battles\Moderation;
|
||||||
use Battles\Nick;
|
|
||||||
use Battles\Template;
|
use Battles\Template;
|
||||||
use Battles\User;
|
use Battles\User;
|
||||||
|
|
||||||
@ -31,56 +29,15 @@ if (isset($_POST['syschatmsg'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//clans to reg
|
//clans to reg
|
||||||
$unregisteredClans = new class {
|
Clan::getUnapprovedList();
|
||||||
|
|
||||||
public function getList()
|
|
||||||
{
|
|
||||||
$row = Db::getInstance()->ofetchAll('SELECT * FROM clans WHERE status = 0');
|
|
||||||
$i = 0;
|
|
||||||
while ($i < count($row)) {
|
|
||||||
$id = $row[$i]->owner_id;
|
|
||||||
$login = User::getInstance($row[$i]->owner_id)->getLogin();
|
|
||||||
$fullName = $row[$i]->full_name;
|
|
||||||
$shortName = $row[$i]->short_name;
|
|
||||||
$info = nl2br($row[$i]->info);
|
|
||||||
$i++;
|
|
||||||
echo <<<UNREGCLANLIST
|
|
||||||
<div>
|
|
||||||
<fieldset style="display: inline;">
|
|
||||||
<legend>$fullName [$shortName]</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;
|
|
||||||
}
|
|
||||||
unset($i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowRegister($id)
|
|
||||||
{
|
|
||||||
Db::getInstance()->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public 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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$unregisteredClans->getList();
|
|
||||||
|
|
||||||
if (isset($_GET['regclan'])) {
|
if (isset($_GET['regclan'])) {
|
||||||
$unregisteredClans->allowRegister($_GET['regclan']);
|
Clan::allowRegister($_GET['regclan']);
|
||||||
header('Location:/admin/admin.php');
|
header('Location:/admin/admin.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (isset($_GET['remclan'])) {
|
if (isset($_GET['remclan'])) {
|
||||||
$unregisteredClans->disallowRegister($_GET['remclan']);
|
Clan::disallowRegister($_GET['remclan']);
|
||||||
header('Location:/admin/admin.php');
|
header('Location:/admin/admin.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
49
classes/Battles/Admin/Clan.php
Normal file
49
classes/Battles/Admin/Clan.php
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user