game/_incl_data/class/Moderation/Announcement.php

49 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace Moderation;
use Chat;
use User;
class Announcement
{
public static function init(): void
{
self::printForm();
self::send();
}
public static function printForm(): void
{
echo <<<HTML
<div style="padding:0 10px 5px 10px; margin:5px; border-bottom:1px solid #cac9c7;">
2023-12-19 01:58:37 +00:00
<h4>Мегафон</h4>
<form method="post"></form>
2023-12-19 01:58:37 +00:00
<label for="announcementText">Сообщение</label>
<input name="announcementText" type="text" id="announcementText" size="70" maxlength="1000">
2023-12-19 01:58:37 +00:00
<input type="submit" name="announcementModeration" id="announcementModeration" class="btn" value="Написать"><br>
<input name="announcementIsSigned" type="checkbox" id="announcementIsSigned" value="1">
2023-12-19 01:58:37 +00:00
<label for="announcementIsSigned">от своего имени</label>
</form>
</div>
HTML;
}
public static function send(): void
{
if (empty($_POST['announcementModeration'] || empty($_POST['announcementText']))) {
return;
}
$strippedMessage = strip_tags($_POST['announcementText']);
if (empty($strippedMessage)) {
return;
}
2023-12-19 01:58:37 +00:00
$sender = empty($_POST['announcementIsSigned']) ? '<b>Администрация</b>' : User::getLogin(User::start()->info['id']);
(new Chat())->sendsys("$sender: $strippedMessage");
2023-12-19 01:58:37 +00:00
echo '<span style="color: red; "><b>Сообщение успешно отправлено</b></span>';
}
}