game/_incl_data/class/Moderation/Moderation.php

119 lines
3.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Moderation;
use Core\Db;
use DateTime;
// todo Запись в личное дело или добавить или убрать остатки.
// todo Заменить уродский костыль с тюремным сундуком. Возможен конфликт с автоудалением предметов!
// todo Понять как мониторить переводы.
class Moderation
{
private const JAIL_ROOM = 274;
private const CENTRAL_SQUARE_ROOM = 9;
private const JAIL_STORAGE = 1357908642; /* Ух, костыль! */
private int $target;
public function __construct(int $userid)
{
$this->target = $userid;
}
/**
* Молчание
* @param DateTime $expiration срок истечения.
* @param string|null $reason причина применения.
*/public function silence(DateTime $expiration, ?string $reason = null)
{
Db::sql('update users set molch1 = ? where id = ?', [$expiration->getTimestamp(), $this->target]);
}
/**
* Снятие молчания
*/
public function unsilence()
{
Db::sql('update users set molch1 = default where id = ?', [$this->target]);
}
/**
* Обезличивание
* @param DateTime $expiration срок истечения.
* @param string|null $reason причина применения.
*/
public function depersonalize(DateTime $expiration, ?string $reason = null)
{
Db::sql('update users set info_delete = ? where id = ?', [$expiration->getTimestamp(), $this->target]);
}
/**
* Снятие обезличивания
*/
public function undepersonalize()
{
Db::sql('update users set info_delete = default where id = ?', [$this->target]);
}
/**
* Тюрьма
* @param DateTime $expiration срок истечения.
* @param string|null $reason причина применения.
*/
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,
]);
}
/**
* Снятие тюрьмы
*/
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,
]);
}
/**
* Блокировка
* @param string|null $reason причина применения.
*/
public function ban(?string $reason = null)
{
Db::sql('update users set banned = unix_timestamp() where id = ?', [$this->target]);
}
/**
* Снятие блокировки
*/
public function unban()
{
Db::sql('update users set banned = default where id = ?', [$this->target]);
}
/**
* Проверка переводов
* @param Target $uid кто проверяется.
* @param DateTime|null $date дата переводов, если не указано - показать все переводы.
*/
public function showItemTransferLogs(Target $uid, ?DateTime $date)
{
// TODO: Implement showItemTransferLogs() method.
}
}