battles/classes/Battles/Moderation.php

87 lines
2.9 KiB
PHP
Raw Permalink Normal View History

<?php
# Date: 25.01.2021 (22:59)
namespace Battles;
use Battles\Database\Db;
class Moderation
{
private const STATUS_OFF = " [снято]";
private static function addEffectStatusToUserLog(int $userId, string $message)
{
$message = "Получен эффект «" . $message . "» до " . date("d.m.Y H:i");
GameLogs::addUserLog($userId, $message, "moderation");
}
public static function muteChat(int $target, int $time)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[2]);
UserEffect::add($target, 2, UserEffect::$effectName[2], $time);
}
public static function unmuteChat(int $target)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[2] . self::STATUS_OFF);
UserEffect::remove($target, 2);
}
public static function muteForum(int $target, int $time)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[3]);
UserEffect::add($target, 3, UserEffect::$effectName[3], $time);
}
public static function unmuteForum(int $target)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[3] . self::STATUS_OFF);
UserEffect::remove($target, 3);
}
public static function hideUserInfo(int $target, int $time)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[5]);
UserEffect::add($target, 5, UserEffect::$effectName[5], $time);
}
public static function unHideUserInfo(int $target)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[5] . self::STATUS_OFF);
UserEffect::remove($target, 5);
}
public static function blockUser(int $target)
{
self::addEffectStatusToUserLog($target, "Блокировка");
Db::getInstance()->execute('UPDATE users SET block = 1 WHERE id = ?', $target);
}
public static function unblockUser(int $target)
{
self::addEffectStatusToUserLog($target, "Блокировка" . self::STATUS_OFF);
Db::getInstance()->execute('UPDATE users SET block = 0 WHERE block = 1 AND id = ?', $target);
}
public static function addToUserLog(int $target, string $message, int $senderId)
{
GameLogs::addUserLog($target, $message, "moderation", $senderId);
}
public static function setAlign(int $target, int $align)
{
Db::getInstance()->execute('UPDATE users SET align = ? WHERE id = ?', [$align, $target]);
}
public static function addChatSysMsg(string $message)
{
Db::getInstance()->execute('INSERT INTO chat (user_id,msg,type) VALUES (-1,?,?)', [$message, 'sys']);
}
public static function addUserCheck(int $target)
{
self::addEffectStatusToUserLog($target, UserEffect::$effectName[20]);
UserEffect::add($target, 20, UserEffect::$effectName[20], strtotime('3days'));
}
2022-12-16 23:20:43 +00:00
}