2023-06-11 23:30:50 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Moderation;
|
|
|
|
|
|
|
|
|
|
use Core\Db;
|
|
|
|
|
use DateTime;
|
2023-12-01 22:28:59 +00:00
|
|
|
|
use Delo;
|
2023-06-11 23:30:50 +00:00
|
|
|
|
|
2023-06-11 23:32:14 +00:00
|
|
|
|
// todo Заменить уродский костыль с тюремным сундуком. Возможен конфликт с автоудалением предметов!
|
|
|
|
|
// todo Понять как мониторить переводы.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
|
|
|
|
|
class Moderation
|
|
|
|
|
{
|
|
|
|
|
private const JAIL_ROOM = 274;
|
|
|
|
|
private const CENTRAL_SQUARE_ROOM = 9;
|
2023-06-11 23:32:14 +00:00
|
|
|
|
private const JAIL_STORAGE = 1357908642; /* Ух, костыль! */
|
2023-12-01 22:28:59 +00:00
|
|
|
|
private const NOT_SET = 'Не указано.';
|
|
|
|
|
private const EXPIRATION_DATETIME_FORMAT = 'd M Y H:i';
|
2023-06-11 23:30:50 +00:00
|
|
|
|
private int $target;
|
|
|
|
|
|
|
|
|
|
public function __construct(int $userid)
|
|
|
|
|
{
|
|
|
|
|
$this->target = $userid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Молчание
|
2023-12-01 22:28:59 +00:00
|
|
|
|
* @param DateTime $expiration срок истечения.
|
|
|
|
|
* @param string $reason причина применения.
|
|
|
|
|
*/
|
|
|
|
|
public function silence(DateTime $expiration, string $reason = self::NOT_SET): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set molch1 = ? where id = ?', [$expiration->getTimestamp(), $this->target]);
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.silence',
|
|
|
|
|
$this->target,
|
|
|
|
|
'Молчанка в чате до ' . $expiration->format(self::EXPIRATION_DATETIME_FORMAT) . '. ' . $reason,
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие молчания
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function unsilence(): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
2023-12-01 22:28:59 +00:00
|
|
|
|
if (Db::getValue('select count(molch1) from users where id = ? and molch1 != 0', [$this->target]) === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-06-11 23:30:50 +00:00
|
|
|
|
Db::sql('update users set molch1 = default where id = ?', [$this->target]);
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.unsilence',
|
|
|
|
|
$this->target,
|
|
|
|
|
'Отмена молчанки.',
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Обезличивание
|
2023-12-01 22:28:59 +00:00
|
|
|
|
* @param DateTime $expiration срок истечения.
|
|
|
|
|
* @param string $reason причина применения.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function depersonalize(DateTime $expiration, string $reason = self::NOT_SET): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set info_delete = ? where id = ?', [$expiration->getTimestamp(), $this->target]);
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.depersonalize',
|
|
|
|
|
$this->target,
|
|
|
|
|
'Скрытие анкеты до ' . $expiration->format(self::EXPIRATION_DATETIME_FORMAT) . '. ' . $reason,
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие обезличивания
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function undepersonalize(): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
2023-12-01 22:28:59 +00:00
|
|
|
|
if (Db::getValue('select count(info_delete) from users where id = ? and info_delete != 0', [$this->target]) === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-06-11 23:30:50 +00:00
|
|
|
|
Db::sql('update users set info_delete = default where id = ?', [$this->target]);
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.undepersonalize',
|
|
|
|
|
$this->target,
|
|
|
|
|
'Раскрытие анкеты.',
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Тюрьма
|
2023-12-01 22:28:59 +00:00
|
|
|
|
* @param DateTime $expiration срок истечения.
|
|
|
|
|
* @param string $reason причина применения.
|
2023-12-01 23:13:29 +00:00
|
|
|
|
* @todo Корректно выбрасывать игрока из подземелья.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function prison(DateTime $expiration, string $reason = self::NOT_SET): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Db::sql('update users set jail = ?, room = ? where id = ?', [$expiration->getTimestamp(), self::JAIL_ROOM, $this->target,]);
|
|
|
|
|
Db::sql('update items_users set `delete` = ? where `delete` = 0 and uid = ?', [self::JAIL_STORAGE, $this->target,]);
|
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.prison',
|
2023-06-11 23:30:50 +00:00
|
|
|
|
$this->target,
|
2023-12-01 22:28:59 +00:00
|
|
|
|
'Тюрьма до ' . $expiration->format(self::EXPIRATION_DATETIME_FORMAT) . '. ' . $reason,
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие тюрьмы
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function unprison(): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Db::sql('update users set jail = default, room = ? where id = ?', [self::CENTRAL_SQUARE_ROOM, $this->target,]);
|
|
|
|
|
Db::sql('update items_users set `delete` = default where `delete` = ? and uid = ?', [self::JAIL_STORAGE, $this->target,]);
|
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.unprison',
|
2023-06-11 23:30:50 +00:00
|
|
|
|
$this->target,
|
2023-12-01 22:28:59 +00:00
|
|
|
|
'Выпуск из тюрьмы.',
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Блокировка
|
2023-12-01 22:28:59 +00:00
|
|
|
|
* @param string $reason причина применения.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function ban(string $reason = self::NOT_SET): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set banned = unix_timestamp() where id = ?', [$this->target]);
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.ban',
|
|
|
|
|
$this->target,
|
|
|
|
|
'Блокировка. ' . $reason,
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие блокировки
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
2023-12-01 22:28:59 +00:00
|
|
|
|
public function unban(): void
|
2023-06-11 23:30:50 +00:00
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set banned = default where id = ?', [$this->target]);
|
2023-12-01 22:28:59 +00:00
|
|
|
|
Delo::add(
|
|
|
|
|
10,
|
|
|
|
|
'moderation.unban',
|
|
|
|
|
$this->target,
|
|
|
|
|
'Снятие блокировки.',
|
|
|
|
|
);
|
2023-06-11 23:30:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Проверка переводов
|
|
|
|
|
* @param Target $uid кто проверяется.
|
|
|
|
|
* @param DateTime|null $date дата переводов, если не указано - показать все переводы.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function showItemTransferLogs(Target $uid, ?DateTime $date)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Implement showItemTransferLogs() method.
|
|
|
|
|
}
|
|
|
|
|
}
|