Reports: Minor fixes and localization

This commit is contained in:
Ilya Prokopenko 2021-12-05 10:57:15 +03:00
parent 47cfafc4c8
commit 88623e0f61
No known key found for this signature in database
GPG key ID: 7736BBBB05F14A56
8 changed files with 42 additions and 14 deletions

View file

@ -70,15 +70,20 @@ class Report extends RowModel
else return null;
}
function getAuthor(): RowModel
{
return (new Posts)->get($this->getContentId())->getOwner();
}
// TODO: Localize that
function banUser()
{
$this->getUser()->ban("Banned by report. Ask Technical support for ban reason");
$this->getAuthor()->ban("Banned by report. Ask Technical support for ban reason");
}
function deleteContent()
{
$this->getUser()->adminNotify("Ваш контент, который вы опубликовали " . $this->getContentObject()->getPublicationTime() . " был удалён модераторами инстанса. За повторные или серьёзные нарушения вас могут заблокировать.");
$this->getAuthor()->adminNotify("Ваш контент, который вы опубликовали " . $this->getContentObject()->getPublicationTime() . " был удалён модераторами инстанса. За повторные или серьёзные нарушения вас могут заблокировать.");
$this->getContentObject()->delete();
$this->setDeleted(1);
$this->save();

View file

@ -22,7 +22,7 @@ class Reports
function getReports(int $state = 0, int $page = 1): \Traversable
{
foreach($this->reports->where(["deleted" => 0])->page($page, 15) as $t)
foreach($this->reports->where(["deleted" => 0])->order("created DESC")->page($page, 15) as $t)
yield new Report($t);
}

View file

@ -18,6 +18,7 @@ final class ReportPresenter extends OpenVKPresenter
function renderList(): void
{
$this->assertUserLoggedIn();
$this->assertPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0);
$this->template->reports = $this->reports->getReports(0, (int)($this->queryParam("p") ?? 1));
@ -32,6 +33,7 @@ final class ReportPresenter extends OpenVKPresenter
function renderView(int $id): void
{
$this->assertUserLoggedIn();
$this->assertPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0);
$report = $this->reports->get($id);

View file

@ -2,10 +2,10 @@
{var iterator = iterator_to_array($reports)}
{var page = $paginatorConf->page}
{block title}Список жалоб{/block}
{block title}{_list_of_reports}{/block}
{block header}
Список жалоб
{_list_of_reports}
{/block}
{block actions}
@ -19,13 +19,13 @@
{/block}
{block preview}
<center><img src="/assets/packages/static/openvk/img/note_icon.png" alt="" style="margin-top: 17px;" /></center>
<center><img src="/assets/packages/static/openvk/img/note_icon.png" style="margin-top: 17px;" /></center>
{/block}
{block name}
{$x->getReason()}
{$x->getAuthor()->getCanonicalName()}
{/block}
{block description}
Текст поста: {$x->getContentObject()->getText()}
{_text_of_the_post}: {$x->getContentObject()->getText()}
{/block}

View file

@ -3,20 +3,20 @@
{block title}{$report->getReason()}{/block}
{block header}
<a href="/admin/reports">Список репортов</a>
<a href="/admin/reports">{_list_of_reports}</a>
»
Жалоба №{$report->getId()}
{_report_number}{$report->getId()}
{/block}
{block content}
<p><b>Комментарий: </b>{$report->getReason()}</p>
<p><b>{_comment}: </b>{$report->getReason()}</p>
{include "../components/post/oldpost.xml", post => $report->getContentObject()}
<center>
<form action="/admin/reportAction{$report->getId()}" method="post">
<input type="hidden" name="hash" value="{$csrfToken}" />
<input type="submit" name="ban" value="Забанить пользователя" class="button">
<input type="submit" name="delete" value="Удалить контент" class="button">
<input type="submit" name="ignore" value="Проигнорировать" class="button">
<input type="submit" name="ban" value="{_ban_user_action}" class="button">
<input type="submit" name="delete" value="{_delete}" class="button">
<input type="submit" name="ignore" value="{_ignore_report}" class="button">
</form>
</center>
{/block}

View file

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS `reports` (
`id` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` bigint(20) NOT NULL,
`target_id` bigint(20) NOT NULL,
`type` varchar(64) NOT NULL,
`reason` text NOT NULL,
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`created` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE `reports` ADD INDEX (`id`);

View file

@ -518,6 +518,11 @@
"support_new_title" = "Enter the topic of your ticket";
"support_new_content" = "Describe the issue or suggestion";
"ignore_report" = "Ignore report";
"report_number" = "Report #";
"list_of_reports" = "List of reports";
"text_of_the_post" = "Text of the post";
"comment" = "Comment";
"sender" = "Sender";

View file

@ -590,6 +590,11 @@
"support_new_title" = "Введите тему вашего обращения";
"support_new_content" = "Опишите проблему или предложение";
"ignore_report" = "Игнорировать жалобу";
"report_number" = "Жалоба №";
"list_of_reports" = "Список жалоб";
"text_of_the_post" = "Текст записи";
"comment" = "Комментарий";
"sender" = "Отправитель";