Перенос разрозненных файлов в фабрику. Утилизация неиспользуемых функций. #49
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?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;">
|
||||
<h4>Ìåãàôîí</h4>
|
||||
<form method="post"></form>
|
||||
<label for="announcementText">Ñîîáùåíèå</label>
|
||||
<input name="announcementText" type="text" id="announcementText" size="70" maxlength="1000">
|
||||
<input type="submit" name="announcementModeration" id="announcementModeration" class="btn" value="Íàïèñàòü"><br>
|
||||
<input name="announcementIsSigned" type="checkbox" id="announcementIsSigned" value="1">
|
||||
<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;
|
||||
}
|
||||
|
||||
$sender = empty($_POST['announcementIsSigned']) ? '<b>Àäìèíèñòðàöèÿ</b>' : User::getLogin(User::start()->info['id']);
|
||||
|
||||
(new Chat())->sendsys("$sender: $strippedMessage");
|
||||
echo '<span style="color: red; "><b>Ñîîáùåíèå óñïåøíî îòïðàâëåíî</b></span>';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user