2023-06-11 23:30:50 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Moderation;
|
|
|
|
|
|
|
|
|
|
use Core\Db;
|
|
|
|
|
use DateTime;
|
|
|
|
|
|
2023-06-11 23:32:14 +00:00
|
|
|
|
// todo Запись в личное дело или добавить или убрать остатки.
|
|
|
|
|
// 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-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
|
|
|
|
* Молчание
|
|
|
|
|
* @param DateTime $expiration срок истечения.
|
|
|
|
|
* @param string|null $reason причина применения.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/public function silence(DateTime $expiration, ?string $reason = null)
|
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set molch1 = ? where id = ?', [$expiration->getTimestamp(), $this->target]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие молчания
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function unsilence()
|
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set molch1 = default where id = ?', [$this->target]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Обезличивание
|
|
|
|
|
* @param DateTime $expiration срок истечения.
|
|
|
|
|
* @param string|null $reason причина применения.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function depersonalize(DateTime $expiration, ?string $reason = null)
|
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set info_delete = ? where id = ?', [$expiration->getTimestamp(), $this->target]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие обезличивания
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function undepersonalize()
|
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set info_delete = default where id = ?', [$this->target]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Тюрьма
|
|
|
|
|
* @param DateTime $expiration срок истечения.
|
|
|
|
|
* @param string|null $reason причина применения.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function prison(DateTime $expiration, ?string $reason = null)
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие тюрьмы
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function unprison()
|
|
|
|
|
{
|
|
|
|
|
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 = ?', [
|
|
|
|
|
1357908642,
|
|
|
|
|
$this->target,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Блокировка
|
|
|
|
|
* @param string|null $reason причина применения.
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function ban(?string $reason = null)
|
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set banned = unix_timestamp() where id = ?', [$this->target]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-11 23:32:14 +00:00
|
|
|
|
* Снятие блокировки
|
2023-06-11 23:30:50 +00:00
|
|
|
|
*/
|
|
|
|
|
public function unban()
|
|
|
|
|
{
|
|
|
|
|
Db::sql('update users set banned = default where id = ?', [$this->target]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
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.
|
|
|
|
|
}
|
|
|
|
|
}
|