2023-12-08 11:39:20 +00:00
|
|
|
|
<?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'],
|
2023-12-19 01:58:37 +00:00
|
|
|
|
'Назначен на пост модератора.'
|
2023-12-08 11:39:20 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function removemoderator(): void
|
|
|
|
|
{
|
|
|
|
|
Moderator::remove($this->targetUser['id']);
|
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.removemoderator',
|
|
|
|
|
$this->targetUser['id'],
|
2023-12-19 01:58:37 +00:00
|
|
|
|
'Уволен с поста модератора.'
|
2023-12-08 11:39:20 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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'],
|
2023-12-19 01:58:37 +00:00
|
|
|
|
'Изменен пол персонажа.'
|
2023-12-08 11:39:20 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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'],
|
2023-12-19 01:58:37 +00:00
|
|
|
|
"Изменен логин персонажа. $this->targetLogin => " . strip_tags($login)
|
2023-12-08 11:39:20 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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'])) {
|
2023-12-19 01:58:37 +00:00
|
|
|
|
$this->status = 'Персонаж не в поединке.';
|
2023-12-08 11:39:20 +00:00
|
|
|
|
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']]);
|
2023-12-19 01:58:37 +00:00
|
|
|
|
// В оригинале тут ещё писалась запись в лог боя, но нужна ли она?
|
2023-12-08 11:39:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|