Fixes and enhancements

This commit is contained in:
n1rwana 2023-08-09 00:29:30 +03:00
parent c93fb477d5
commit 02a393b79f
No known key found for this signature in database
GPG key ID: 1D319A83686EC843
14 changed files with 71 additions and 27 deletions

View file

@ -72,6 +72,7 @@ class Report extends RowModel
else if ($this->getContentType() == "comment") return (new Comments)->get($this->getContentId()); else if ($this->getContentType() == "comment") return (new Comments)->get($this->getContentId());
else if ($this->getContentType() == "note") return (new Notes)->get($this->getContentId()); else if ($this->getContentType() == "note") return (new Notes)->get($this->getContentId());
else if ($this->getContentType() == "app") return (new Applications)->get($this->getContentId()); else if ($this->getContentType() == "app") return (new Applications)->get($this->getContentId());
else if ($this->getContentType() == "user") return (new Users)->get($this->getContentId());
else return null; else return null;
} }
@ -82,15 +83,18 @@ class Report extends RowModel
function banUser($initiator) function banUser($initiator)
{ {
$this->getAuthor()->ban("**content-" . $this->getContentType() . "-" . $this->getContentId() . "**", false, time() + $this->getAuthor()->getNewBanTime(), $initiator); $reason = $this->getContentType() !== "user" ? ("**content-" . $this->getContentType() . "-" . $this->getContentId() . "**") : ("Подозрительная активность");
$this->getAuthor()->ban($reason, false, time() + $this->getAuthor()->getNewBanTime(), $initiator);
} }
function deleteContent() function deleteContent()
{ {
if ($this->getContentType() !== "user") {
$pubTime = $this->getContentObject()->getPublicationTime(); $pubTime = $this->getContentObject()->getPublicationTime();
$name = $this->getContentObject()->getName(); $name = $this->getContentObject()->getName();
$this->getAuthor()->adminNotify("Ваш контент, который вы опубликовали $pubTime ($name) был удалён модераторами инстанса. За повторные или серьёзные нарушения вас могут заблокировать."); $this->getAuthor()->adminNotify("Ваш контент, который вы опубликовали $pubTime ($name) был удалён модераторами инстанса. За повторные или серьёзные нарушения вас могут заблокировать.");
$this->getContentObject()->delete($this->getContentType() !== "app"); $this->getContentObject()->delete($this->getContentType() !== "app");
}
$this->setDeleted(1); $this->setDeleted(1);
$this->save(); $this->save();
} }

View file

@ -264,10 +264,10 @@ class User extends RowModel
$reason = $ban->getReason(); $reason = $ban->getReason();
preg_match('/\*\*content-(post|photo|video|group|comment|note|app|noSpamTemplate)-(\d+)\*\*$/', $reason, $matches); preg_match('/\*\*content-(post|photo|video|group|comment|note|app|noSpamTemplate|user)-(\d+)\*\*$/', $reason, $matches);
if (sizeof($matches) === 3) { if (sizeof($matches) === 3) {
$content_type = $matches[1]; $content_id = (int) $matches[2]; $content_type = $matches[1]; $content_id = (int) $matches[2];
if ($content_type === "noSpamTemplate") { if (in_array($content_type, ["noSpamTemplate", "user"])) {
$reason = "Подозрительная активность"; $reason = "Подозрительная активность";
} else { } else {
if ($for !== "banned") { if ($for !== "banned") {
@ -282,6 +282,7 @@ class User extends RowModel
case "comment": $reason[] = (new Comments)->get($content_id); break; case "comment": $reason[] = (new Comments)->get($content_id); break;
case "note": $reason[] = (new Notes)->get($content_id); break; case "note": $reason[] = (new Notes)->get($content_id); break;
case "app": $reason[] = (new Applications)->get($content_id); break; case "app": $reason[] = (new Applications)->get($content_id); break;
case "user": $reason[] = (new Users)->get($content_id); break;
default: $reason[] = null; default: $reason[] = null;
} }
} }
@ -1171,6 +1172,7 @@ class User extends RowModel
{ {
$ban = (new Bans)->get((int) $this->getRecord()->block_reason); $ban = (new Bans)->get((int) $this->getRecord()->block_reason);
if (!$ban || $ban->isOver() || $ban->isPermanent()) return null; if (!$ban || $ban->isOver() || $ban->isPermanent()) return null;
if ($this->canUnbanThemself()) return tr("today");
return date('d.m.Y', $ban->getEndTime()); return date('d.m.Y', $ban->getEndTime());
} }

View file

@ -32,7 +32,7 @@ final class NoSpamPresenter extends OpenVKPresenter
$this->assertPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0); $this->assertPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0);
$targetDir = __DIR__ . '/../Models/Entities/'; $targetDir = __DIR__ . '/../Models/Entities/';
$mode = in_array($this->queryParam("act"), ["form", "templates", "rollback"]) ? $this->queryParam("act") : "form"; $mode = in_array($this->queryParam("act"), ["form", "templates", "rollback", "reports"]) ? $this->queryParam("act") : "form";
if ($mode === "form") { if ($mode === "form") {
$this->template->_template = "NoSpam/Index"; $this->template->_template = "NoSpam/Index";
@ -70,6 +70,8 @@ final class NoSpamPresenter extends OpenVKPresenter
$filter["id"] = (int)$this->queryParam("id"); $filter["id"] = (int)$this->queryParam("id");
} }
$this->template->templates = iterator_to_array((new NoSpamLogs)->getList($filter)); $this->template->templates = iterator_to_array((new NoSpamLogs)->getList($filter));
} else if ($mode === "reports") {
$this->redirect("/scumfeed");
} else { } else {
$template = (new NoSpamLogs)->get((int)$this->postParam("id")); $template = (new NoSpamLogs)->get((int)$this->postParam("id"));
if (!$template || $template->isRollbacked()) if (!$template || $template->isRollbacked())

View file

@ -51,7 +51,7 @@ final class ReportPresenter extends OpenVKPresenter
if(!$id) if(!$id)
exit(json_encode([ "error" => tr("error_segmentation") ])); exit(json_encode([ "error" => tr("error_segmentation") ]));
if(in_array($this->queryParam("type"), ["post", "photo", "video", "group", "comment", "note", "app"])) { if(in_array($this->queryParam("type"), ["post", "photo", "video", "group", "comment", "note", "app", "user"])) {
$report = new Report; $report = new Report;
$report->setUser_id($this->user->id); $report->setUser_id($this->user->id);
$report->setTarget_id($id); $report->setTarget_id($id);

View file

@ -4,7 +4,7 @@
{block header}{include title}{/block} {block header}{include title}{/block}
{block content} {block content}
{include "Tabs.xml", mode => "form"} <div class="tabs">{include "Tabs.xml", mode => "form"}</div>
<br/> <br/>
<div style="display: flex; border: 1px solid #ECECEC; padding: 8px;"> <div style="display: flex; border: 1px solid #ECECEC; padding: 8px;">
<div id="noSpam-form" style="width: 50%; border-right: 1px solid #ECECEC;"> <div id="noSpam-form" style="width: 50%; border-right: 1px solid #ECECEC;">

View file

@ -1,8 +1,9 @@
<div class="tabs"> <div n:attr="id => ($mode === 'form' ? 'activetabs' : 'ki')" class="tab">
<div n:attr="id => ($mode === 'form' ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($mode === 'form' ? 'act_tab_a' : 'ki')" href="/noSpam">Бан по шаблону</a> <a n:attr="id => ($mode === 'form' ? 'act_tab_a' : 'ki')" href="/noSpam">Бан по шаблону</a>
</div> </div>
<div n:attr="id => ($mode === 'templates' ? 'activetabs' : 'ki')" class="tab"> <div n:attr="id => ($mode === 'templates' ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($mode === 'templates' ? 'act_tab_a' : 'ki')" href="/noSpam?act=templates">Действующие шаблоны</a> <a n:attr="id => ($mode === 'templates' ? 'act_tab_a' : 'ki')" href="/noSpam?act=templates">Действующие шаблоны</a>
</div> </div>
<div n:attr="id => ($mode === 'reports' ? 'activetabs' : 'ki')" class="tab">
<a n:attr="id => ($mode === 'reports' ? 'act_tab_a' : 'ki')" href="/scumfeed">Жалобы пользователей</a>
</div> </div>

View file

@ -4,7 +4,7 @@
{block header}{include title}{/block} {block header}{include title}{/block}
{block content} {block content}
{include "Tabs.xml", mode => "templates"} <div class="tabs">{include "Tabs.xml", mode => "templates"}</div>
<style> <style>
table, th, td { table, th, td {

View file

@ -2,6 +2,8 @@
{var iterator = iterator_to_array($reports)} {var iterator = iterator_to_array($reports)}
{var page = $paginatorConf->page} {var page = $paginatorConf->page}
{block tabs}{include "../NoSpam/Tabs.xml", mode => "reports"}{/block}
{block title}{_list_of_reports}{/block} {block title}{_list_of_reports}{/block}
{block header} {block header}
@ -39,6 +41,8 @@
{_comment} {_comment}
{elseif $x->getContentType() == "app"} {elseif $x->getContentType() == "app"}
{_app} {_app}
{elseif $x->getContentType() == "user"}
{_users}
{else} {else}
Unknown Unknown
{/if} {/if}

View file

@ -9,19 +9,23 @@
{/block} {/block}
{block content} {block content}
<p><b>{_comment}: </b>{$report->getReason()}</p> <div class="tabs">{include "../NoSpam/Tabs.xml", mode => "reports"}</div>
<br />
<p>
<b>{_comment}:</b> {$report->getReason()}
</p>
{include "ViewContent.xml", type => $report->getContentType(), object => $report->getContentObject()} {include "ViewContent.xml", type => $report->getContentType(), object => $report->getContentObject()}
<center> <center>
<form action="/admin/reportAction{$report->getId()}" method="post"> <form action="/admin/reportAction{$report->getId()}" method="post">
<center> <center>
<form n:if="$report->getContentType() != 'group'" action="/admin/reportAction{$report->getId()}" method="post"> <form n:if="$report->getContentType() != 'group'" action="/admin/reportAction{$report->getId()}" method="post">
<input type="hidden" name="hash" value="{$csrfToken}" /> <input type="hidden" name="hash" value="{$csrfToken}"/>
<input type="submit" name="ban" value="{_ban_user_action}" 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="delete" value="{_delete}" class="button">
<input type="submit" name="ignore" value="{_ignore_report}" class="button"> <input type="submit" name="ignore" value="{_ignore_report}" class="button">
</form> </form>
<form n:if="$report->getContentType() == 'group'" action="/admin/reportAction{$report->getId()}" method="post"> <form n:if="$report->getContentType() == 'group'" action="/admin/reportAction{$report->getId()}" method="post">
<input type="hidden" name="hash" value="{$csrfToken}" /> <input type="hidden" name="hash" value="{$csrfToken}"/>
<input type="submit" name="banClubOwner" value="Заблокировать создателя" class="button"> <input type="submit" name="banClubOwner" value="Заблокировать создателя" class="button">
<input type="submit" name="banClub" value="Заблокировать группу" class="button"> <input type="submit" name="banClub" value="Заблокировать группу" class="button">
<input type="submit" name="ignore" value="{_ignore_report}" class="button"> <input type="submit" name="ignore" value="{_ignore_report}" class="button">

View file

@ -13,8 +13,8 @@
{include "./content/photo.xml", photo => $object} {include "./content/photo.xml", photo => $object}
{elseif $type == "video"} {elseif $type == "video"}
{include "./content/video.xml", video => $object} {include "./content/video.xml", video => $object}
{elseif $type == "group"} {elseif $type == "group" || $type == "user"}
{include "../components/group.xml", group => $object} {include "../components/group.xml", group => $object, isUser => $type == "user"}
{elseif $type == "comment"} {elseif $type == "comment"}
{include "../components/comment.xml", comment => $object, timeOnly => true} {include "../components/comment.xml", comment => $object, timeOnly => true}
{elseif $type == "note"} {elseif $type == "note"}

View file

@ -169,6 +169,31 @@
<input type="submit" class="profile_link" value="{_friends_delete}" style="width: 194px;" /> <input type="submit" class="profile_link" value="{_friends_delete}" style="width: 194px;" />
</form> </form>
{/if} {/if}
<a class="profile_link" style="display:block;width:96%;" href="javascript:reportUser()">{_report}</a>
<script>
function reportUser() {
uReportMsgTxt = "Вы собираетесь пожаловаться на данного пользователя.";
uReportMsgTxt += "<br/>Что именно вам кажется недопустимым в этом материале?";
uReportMsgTxt += "<br/><br/><b>Причина жалобы</b>: <input type='text' id='uReportMsgInput' placeholder='Причина' />"
MessageBox("Пожаловаться?", uReportMsgTxt, ["Подтвердить", "Отмена"], [
(function() {
res = document.querySelector("#uReportMsgInput").value;
xhr = new XMLHttpRequest();
xhr.open("GET", "/report/" + {$user->getId()} + "?reason=" + res + "&type=user", true);
xhr.onload = (function() {
if(xhr.responseText.indexOf("reason") === -1)
MessageBox("Ошибка", "Не удалось подать жалобу...", ["OK"], [Function.noop]);
else
MessageBox("Операция успешна", "Скоро её рассмотрят модераторы", ["OK"], [Function.noop]);
});
xhr.send(null);
}),
Function.noop
]);
}
</script>
{/if} {/if}
<a style="width: 194px;" n:if="$user->getFollowersCount() > 0" href="/friends{$user->getId()}?act=incoming" class="profile_link">{tr("followers", $user->getFollowersCount())}</a> <a style="width: 194px;" n:if="$user->getFollowersCount() > 0" href="/friends{$user->getId()}?act=incoming" class="profile_link">{tr("followers", $user->getFollowersCount())}</a>
</div> </div>

View file

@ -5,7 +5,7 @@
<tr> <tr>
<td valign="top"> <td valign="top">
<a href="{$group->getURL()}"> <a href="{$group->getURL()}">
<img src="{$group->getAvatarURL('miniscule')}" width="75" alt="Фотография группы"> <img src="{$group->getAvatarURL('normal')}" width="75" alt="Фотография">
</a> </a>
</td> </td>
<td valign="top" style="width: 100%"> <td valign="top" style="width: 100%">
@ -16,14 +16,14 @@
<span class="nobold">{_name}:</span> <span class="nobold">{_name}:</span>
</td> </td>
<td class="data"> <td class="data">
<a href="{$group->getURL()}">{$group->getName()}</a> <a href="{$group->getURL()}">{!$isUser ? $group->getName() : $group->getCanonicalName()}</a>
<img n:if="$group->isVerified()" <img n:if="$group->isVerified()"
class="name-checkmark" class="name-checkmark"
src="/assets/packages/static/openvk/img/checkmark.png" src="/assets/packages/static/openvk/img/checkmark.png"
/> />
</td> </td>
</tr> </tr>
<tr> <tr n:if="!$isUser">
<td class="label"> <td class="label">
<span class="nobold">{_size}:</span> <span class="nobold">{_size}:</span>
</td> </td>

View file

@ -905,6 +905,7 @@
"report_number" = "Report #"; "report_number" = "Report #";
"list_of_reports" = "List of reports"; "list_of_reports" = "List of reports";
"text_of_the_post" = "Text of the post"; "text_of_the_post" = "Text of the post";
"today" = "today";
"comment" = "Comment"; "comment" = "Comment";
"sender" = "Sender"; "sender" = "Sender";

View file

@ -840,6 +840,7 @@
"report_number" = "Жалоба №"; "report_number" = "Жалоба №";
"list_of_reports" = "Список жалоб"; "list_of_reports" = "Список жалоб";
"text_of_the_post" = "Текст записи"; "text_of_the_post" = "Текст записи";
"today" = "сегодня";
"comment" = "Комментарий"; "comment" = "Комментарий";
"sender" = "Отправитель"; "sender" = "Отправитель";