battles/classes/Battles/Moderation.php

86 lines
3.0 KiB
PHP

<?php
# Date: 25.01.2021 (22:59)
namespace Battles;
use Battles\Database\DBPDO;
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): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[2]);
return User::setUserEffect($target, 2, UserEffects::$effectName[2], $time);
}
public static function unmuteChat(int $target): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[2] . self::STATUS_OFF);
return User::removeUserEffect($target, 2);
}
public static function muteForum(int $target, int $time): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[3]);
return User::setUserEffect($target, 3, UserEffects::$effectName[3], $time);
}
public static function unmuteForum(int $target): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[3] . self::STATUS_OFF);
return User::removeUserEffect($target, 3);
}
public static function hideUserInfo(int $target, int $time): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[5]);
return User::setUserEffect($target, 5, UserEffects::$effectName[5], $time);
}
public static function unHideUserInfo(int $target): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[5] . self::STATUS_OFF);
return User::removeUserEffect($target, 5);
}
public static function blockUser(int $target): void
{
self::addEffectStatusToUserLog($target, "Блокировка");
DBPDO::INIT()->execute('UPDATE battles.users SET block = 1 WHERE id = ?', $target);
}
public static function unBlockUser(int $target): void
{
self::addEffectStatusToUserLog($target, "Блокировка" . self::STATUS_OFF);
DBPDO::INIT()->execute('UPDATE battles.users SET block = 0 WHERE block = 1 AND id = ?', $target);
}
public static function addToUserLog(int $target, string $message, int $senderId): void
{
GameLogs::addUserLog($target, $message, "moderation", $senderId);
}
public static function setAlign(int $target, int $align): void
{
DBPDO::INIT()->execute('UPDATE users SET align = ? WHERE id = ?', [$align, $target]);
}
public static function addChatSysMsg(string $message): void
{
DBPDO::INIT()->execute('INSERT INTO chat (user_id,msg,type) VALUES (-1,?,?)', [$message, 'sys']);
}
public static function addUserCheck(int $target): bool
{
self::addEffectStatusToUserLog($target, UserEffects::$effectName[20]);
return User::setUserEffect($target, 20, UserEffects::$effectName[20], strtotime('3days'));
}
}