99 lines
2.7 KiB
PHP
99 lines
2.7 KiB
PHP
<?php
|
||
|
||
namespace Moderation;
|
||
|
||
use Core\Db;
|
||
use Delo;
|
||
use User;
|
||
|
||
class AdmFactory
|
||
{
|
||
public readonly string $status;
|
||
private array $targetUser;
|
||
|
||
public function __construct(
|
||
private readonly string $targetLogin,
|
||
)
|
||
{
|
||
$this->targetUser = User::getInfo($this->targetLogin);
|
||
}
|
||
|
||
public function addmoderator(): void
|
||
{
|
||
Moderator::add($this->targetUser['id']);
|
||
Delo::add(
|
||
10,
|
||
'moderation.addmoderator',
|
||
$this->targetUser['id'],
|
||
'Назначен на пост модератора.'
|
||
);
|
||
}
|
||
|
||
public function removemoderator(): void
|
||
{
|
||
Moderator::remove($this->targetUser['id']);
|
||
Delo::add(
|
||
10,
|
||
'moderation.removemoderator',
|
||
$this->targetUser['id'],
|
||
'Уволен с поста модератора.'
|
||
);
|
||
}
|
||
|
||
public function changegender(): void
|
||
{
|
||
$changeto = $this->targetUser['sex'] == 0 ? 1 : 0;
|
||
Db::sql('update users set sex = ? where id = ?', [$changeto, $this->targetUser['id']]);
|
||
Delo::add(
|
||
10,
|
||
'moderation.changegender',
|
||
$this->targetUser['id'],
|
||
'Изменен пол персонажа.'
|
||
);
|
||
}
|
||
|
||
public function changelogin(string $login): void
|
||
{
|
||
$newlogin = strip_tags($login);
|
||
if (empty($newlogin)) {
|
||
return;
|
||
}
|
||
Db::sql('update users set login = ? where login = ?', [strip_tags($login), $this->targetLogin]);
|
||
Delo::add(
|
||
10,
|
||
'moderation.changelogin',
|
||
$this->targetUser['id'],
|
||
"Изменен логин персонажа. $this->targetLogin => " . strip_tags($login)
|
||
);
|
||
}
|
||
|
||
public function toggleinvisibility(): void
|
||
{
|
||
$changeto = $this->targetUser['invis'] == 0 ? 1 : 0;
|
||
Db::sql('update users set invis = ? where id = ?', [$changeto, $this->targetUser['id']]);
|
||
}
|
||
|
||
public function additem(int $itemId): void
|
||
{
|
||
if ($itemId < 1) {
|
||
return;
|
||
}
|
||
User\ItemsModel::addItem($itemId, $this->targetUser['id']);
|
||
}
|
||
|
||
public function kickfrombattle(): void
|
||
{
|
||
if (empty($this->targetUser['battle'])) {
|
||
$this->status = 'Персонаж не в поединке.';
|
||
return;
|
||
}
|
||
Db::sql('update users left join stats on users.id = stats.id
|
||
set
|
||
battle = default,
|
||
team = default,
|
||
battle_yron = default,
|
||
battle_exp = default
|
||
where id = ?', [$this->targetUser['id']]);
|
||
// В оригинале тут ещё писалась запись в лог боя, но нужна ли она?
|
||
}
|
||
} |