From a2775be423aef827b968852f7cc20c4f34e9efad Mon Sep 17 00:00:00 2001 From: Ivor Barhansky <me@lopar.space> Date: Mon, 12 Jun 2023 02:30:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D1=86=D0=B5=D1=81=D1=81=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=BD=D0=B0=D0=B4=20#49?= =?UTF-8?q?.=20=D0=92=D1=81=D0=B5=20=D0=B7=D0=B0=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=B3=D0=BE=D0=B2=D0=BE=D1=80=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=BC=D0=BE=D0=B4=D0=B5=D1=80=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=81=D0=BA=D0=B8=D0=B5=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B2=20=D0=BE=D0=B4=D0=BD=D0=BE=D0=BC=20=D1=84?= =?UTF-8?q?=D0=BB=D0=B0=D0=BA=D0=BE=D0=BD=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _incl_data/class/Moderation/Moderation.php | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 _incl_data/class/Moderation/Moderation.php diff --git a/_incl_data/class/Moderation/Moderation.php b/_incl_data/class/Moderation/Moderation.php new file mode 100644 index 00000000..78f66114 --- /dev/null +++ b/_incl_data/class/Moderation/Moderation.php @@ -0,0 +1,119 @@ +<?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. + } +} \ No newline at end of file