mirror of
https://github.com/openvk/openvk
synced 2025-07-01 13:38:15 +03:00
parent
af5df61f73
commit
8fb393ca9b
15 changed files with 223 additions and 18 deletions
|
@ -351,9 +351,15 @@ class Club extends RowModel
|
|||
}
|
||||
|
||||
function getWebsite(): ?string
|
||||
{
|
||||
return $this->getRecord()->website;
|
||||
}
|
||||
{
|
||||
return $this->getRecord()->website;
|
||||
}
|
||||
|
||||
function ban(string $reason): void
|
||||
{
|
||||
$this->setBlock_Reason($reason);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
function getAlert(): ?string
|
||||
{
|
||||
|
|
|
@ -4,8 +4,7 @@ use openvk\Web\Util\DateTime;
|
|||
use Nette\Database\Table\ActiveRow;
|
||||
use openvk\Web\Models\RowModel;
|
||||
use Chandler\Database\DatabaseConnection;
|
||||
use openvk\Web\Models\Repositories\Users;
|
||||
use openvk\Web\Models\Repositories\Posts;
|
||||
use openvk\Web\Models\Repositories\{Users, Posts, Photos, Videos, Clubs};
|
||||
use Chandler\Database\DatabaseConnection as DB;
|
||||
use Nette\InvalidStateException as ISE;
|
||||
use Nette\Database\Table\Selection;
|
||||
|
@ -67,6 +66,9 @@ class Report extends RowModel
|
|||
function getContentObject()
|
||||
{
|
||||
if ($this->getContentType() == "post") return (new Posts)->get($this->getContentId());
|
||||
else if ($this->getContentType() == "photo") return (new Photos)->get($this->getContentId());
|
||||
else if ($this->getContentType() == "video") return (new Videos)->get($this->getContentId());
|
||||
else if ($this->getContentType() == "group") return (new Clubs)->get($this->getContentId());
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ final class ReportPresenter extends OpenVKPresenter
|
|||
exit(json_encode([ "error" => tr("error_segmentation") ]));
|
||||
|
||||
// At this moment, only Posts will be implemented
|
||||
if($this->queryParam("type") == 'post') {
|
||||
if(in_array($this->queryParam("type"), ["post", "photo", "video", "group"])) {
|
||||
$post = (new Posts)->get(intval($id));
|
||||
if(!$post)
|
||||
exit(json_encode([ "error" => "Unable to report nonexistent content" ]));
|
||||
|
@ -77,10 +77,11 @@ final class ReportPresenter extends OpenVKPresenter
|
|||
$this->willExecuteWriteAction();
|
||||
$this->assertPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0);
|
||||
|
||||
if($this->postParam("ban")) {
|
||||
$report = $this->reports->get($id);
|
||||
if(!$report) $this->notFound();
|
||||
if($report->isDeleted()) $this->notFound();
|
||||
$report = $this->reports->get($id);
|
||||
if(!$report) $this->notFound();
|
||||
if($report->isDeleted()) $this->notFound();
|
||||
|
||||
if($this->postParam("ban")) {
|
||||
if(is_null($this->user))
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
|
@ -88,23 +89,40 @@ final class ReportPresenter extends OpenVKPresenter
|
|||
$report->deleteContent();
|
||||
$this->flash("suc", "Смэрть...", "Пользователь успешно забанен.");
|
||||
}else if($this->postParam("delete")){
|
||||
$report = $this->reports->get($id);
|
||||
if(!$report) $this->notFound();
|
||||
if($report->isDeleted()) $this->notFound();
|
||||
if(is_null($this->user))
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
$report->deleteContent();
|
||||
$this->flash("suc", "Нехай живе!", "Контент удалён, а пользователю прилетело предупреждение.");
|
||||
}else if($this->postParam("ignore")){
|
||||
$report = $this->reports->get($id);
|
||||
if(!$report) $this->notFound();
|
||||
if($report->isDeleted()) $this->notFound();
|
||||
if(is_null($this->user))
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
$report->setDeleted();
|
||||
$report->delete();
|
||||
$this->flash("suc", "Нехай живе!", "Жалоба проигнорирована.");
|
||||
}else if($this->postParam("banClubOwner")) {
|
||||
if($report->getContentType() != "group")
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
$club = $report->getContentObject();
|
||||
|
||||
if(is_null($club))
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
$owner = $club->getOwner();
|
||||
$owner->ban("Banned by report. Ask Technical support for ban reason");
|
||||
|
||||
$report->delete();
|
||||
$this->flash("suc", "Смэрть...", "Создатель сообщества успешно забанен.");
|
||||
}else if($this->postParam("banClub")) {
|
||||
if($report->getContentType() != "group")
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
$club = $report->getContentObject();
|
||||
$club->ban("Banned by report. Ask Technical support for ban reason");
|
||||
|
||||
$report->delete();
|
||||
$this->flash("suc", "Смэрть...", "Сообщество успешно забанено.");
|
||||
}
|
||||
$this->redirect("/support/reports");
|
||||
}
|
||||
|
|
|
@ -186,6 +186,19 @@
|
|||
(<b>{$helpdeskTicketNotAnsweredCount}</b>)
|
||||
{/if}
|
||||
</a>
|
||||
<a href="/admin/reports" class="link">{tr("reports")}</a>
|
||||
{/if}
|
||||
<a
|
||||
n:foreach="OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links'] as $menuItem"
|
||||
href="{$menuItem['url']}"
|
||||
target="_blank"
|
||||
class="link">{$menuItem["name"]}</a>
|
||||
<div id="_groupListPinnedGroups">
|
||||
<div n:if="$thisUser->getPinnedClubCount() > 0" class="menu_divider"></div>
|
||||
<a
|
||||
n:foreach="$thisUser->getPinnedClubs() as $club"
|
||||
href="{$club->getURL()}"
|
||||
class="link group_link">{$club->getName()}</a>
|
||||
<a href="/admin/support/reports" class="link" n:if="$canAccessHelpdesk">Reports
|
||||
{if $reportNotAnsweredCount > 0}
|
||||
(<b>{$reportNotAnsweredCount}</b>)
|
||||
|
|
|
@ -120,6 +120,34 @@
|
|||
<input type="submit" id="profile_link" value="{_leave_community}" />
|
||||
</form>
|
||||
{/if}
|
||||
{var $canReport = $thisUser->getId() != $club->getOwner()->getId()}
|
||||
{if $canReport}
|
||||
<a class="profile_link" style="display:block;width:96%;" href="javascript:reportVideo()">{_report}</a>
|
||||
|
||||
<script>
|
||||
function reportVideo() {
|
||||
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.pl/" + {$club->getId()} + "?reason=" + res + "&type=group", 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}
|
||||
</div>
|
||||
<div>
|
||||
<div class="content_title_expanded" onclick="hidePanel(this);">
|
||||
|
|
|
@ -42,10 +42,38 @@
|
|||
</div>
|
||||
<br/>
|
||||
<h4>{_actions}</h4>
|
||||
{if $thisUser->getId() != $photo->getOwner()->getId()}
|
||||
{var canReport = true}
|
||||
{/if}
|
||||
<div n:if="isset($thisUser) && $thisUser->getId() === $photo->getOwner()->getId()">
|
||||
<a href="/photo{$photo->getPrettyId()}/edit" class="profile_link" style="display:block;width:96%;">{_edit}</a>
|
||||
<a id="_photoDelete" href="/photo{$photo->getPrettyId()}/delete" class="profile_link" style="display:block;width:96%;">{_delete}</a>
|
||||
</div>
|
||||
<a href="{$photo->getURL()}" class="profile_link" target="_blank" style="display:block;width:96%;">{_"open_original"}</a>
|
||||
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportPhoto()">{_report}</a>
|
||||
<script n:if="$canReport ?? false">
|
||||
function reportPhoto() {
|
||||
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.pl/" + {$photo->getId()} + "?reason=" + res + "&type=photo", 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>
|
||||
<a href="{$photo->getURL()}" class="profile_link" target="_blank" style="display:block;width:96%;">{_open_original}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -27,5 +27,15 @@
|
|||
{/block}
|
||||
|
||||
{block description}
|
||||
{_text_of_the_post}: {$x->getContentObject()->getText()}
|
||||
{if $x->getContentType() == "post"}
|
||||
{_text_of_the_post}: {$x->getContentObject()->getText()}
|
||||
{elseif $x->getContentType() == "photo"}
|
||||
{_photo}
|
||||
{elseif $x->getContentType() == "video"}
|
||||
{_video}
|
||||
{elseif $x->getContentType() == "group"}
|
||||
{_groups}
|
||||
{else}
|
||||
Unknown
|
||||
{/if}
|
||||
{/block}
|
||||
|
|
|
@ -10,6 +10,19 @@
|
|||
|
||||
{block content}
|
||||
<p><b>{_comment}: </b>{$report->getReason()}</p>
|
||||
{if $report->getContentType() == "post"}
|
||||
{include "../components/post/oldpost.xml", post => $report->getContentObject()}
|
||||
{elseif $report->getContentType() == "photo"}
|
||||
{include "../components/photo.xml", photo => $report->getContentObject()}
|
||||
{elseif $report->getContentType() == "video"}
|
||||
{include "../components/video.xml", video => $report->getContentObject()}
|
||||
{elseif $report->getContentType() == "group"}
|
||||
{include "../components/group.xml", group => $report->getContentObject()}
|
||||
{else}
|
||||
Error
|
||||
{/if}
|
||||
<center>
|
||||
<form n:if="$report->getContentType() != 'group'" action="/admin/reportAction{$report->getId()}" method="post">
|
||||
{include "../components/post/oldpost.xml", post => $report->getContentObject(), forceNoPinLink => TRUE, forceNoDeleteLink => TRUE, forceNoShareLink => TRUE, forceNoLike => TRUE}
|
||||
<center>
|
||||
<form action="/admin/support/reportAction{$report->getId()}" method="post">
|
||||
|
@ -18,5 +31,11 @@
|
|||
<input type="submit" name="delete" value="{_delete}" class="button">
|
||||
<input type="submit" name="ignore" value="{_ignore_report}" class="button">
|
||||
</form>
|
||||
<form n:if="$report->getContentType() == 'group'" action="/admin/reportAction{$report->getId()}" method="post">
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
<input type="submit" name="banClubOwner" value="Заблокировать создателя" class="button">
|
||||
<input type="submit" name="banClub" value="Заблокировать группу" class="button">
|
||||
<input type="submit" name="ignore" value="{_ignore_report}" class="button">
|
||||
</form>
|
||||
</center>
|
||||
{/block}
|
||||
|
|
|
@ -57,6 +57,38 @@
|
|||
{_delete}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{if isset($thisUser)}
|
||||
{if $thisUser->getId() != $video->getOwner()->getId()}
|
||||
{var canReport = true}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<a n:if="$canReport ?? false" class="profile_link" style="display:block;width:96%;" href="javascript:reportVideo()">{_report}</a>
|
||||
|
||||
<script n:if="$canReport ?? false">
|
||||
function reportVideo() {
|
||||
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.pl/" + {$video->getId()} + "?reason=" + res + "&type=video", 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>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
|
22
Web/Presenters/templates/components/group.xml
Normal file
22
Web/Presenters/templates/components/group.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
{block content}
|
||||
<div class="content">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<a href="{$group->getURL()}">
|
||||
<img src="{$group->getAvatarURL()}" width="75" alt="Фотография группы">
|
||||
</a>
|
||||
</td>
|
||||
<td valign="top" style="width: 100%">
|
||||
<a href="{$group->getURL()}">
|
||||
<b>
|
||||
asdasdasd
|
||||
</b>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/block}
|
5
Web/Presenters/templates/components/photo.xml
Normal file
5
Web/Presenters/templates/components/photo.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
{block content}
|
||||
<center style="margin-bottom: 8pt;">
|
||||
<img src="{$photo->getURL()}" style="max-width: 80%; max-height: 60vh;" />
|
||||
</center>
|
||||
{/block}
|
14
Web/Presenters/templates/components/video.xml
Normal file
14
Web/Presenters/templates/components/video.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
{block content}
|
||||
<center style="margin-bottom: 8pt;">
|
||||
{if $video->getType() === 0}
|
||||
<video width="610" src="{$video->getURL()}" controls></video>
|
||||
{else}
|
||||
{var driver = $video->getVideoDriver()}
|
||||
{if !$driver}
|
||||
Эта видеозапись не поддерживается в вашей версии OpenVK.
|
||||
{else}
|
||||
{$driver->getEmbed()|noescape}
|
||||
{/if}
|
||||
{/if}
|
||||
</center>
|
||||
{/block}
|
|
@ -307,6 +307,10 @@ routes:
|
|||
handler: "Support->quickUnbanInSupport"
|
||||
- url: "/admin/support/reports"
|
||||
handler: "Report->list"
|
||||
- url: "/scumfeed"
|
||||
handler: "Report->list"
|
||||
- url: "/admin/report{num}"
|
||||
handler: "Report->view"
|
||||
- url: "/admin/support/report{num}"
|
||||
handler: "Report->view"
|
||||
- url: "/admin/support/reportAction{num}"
|
||||
|
|
|
@ -804,6 +804,8 @@
|
|||
"support_new_title" = "Enter the topic of your ticket";
|
||||
"support_new_content" = "Describe the issue or suggestion";
|
||||
|
||||
"reports" = "Reports";
|
||||
|
||||
"support_rate_good_answer" = "This is good answer";
|
||||
"support_rate_bad_answer" = "This is bad answer";
|
||||
"support_good_answer_user" = "You left a positive feedback.";
|
||||
|
|
|
@ -849,6 +849,8 @@
|
|||
"support_new_title" = "Введите тему вашего обращения";
|
||||
"support_new_content" = "Опишите проблему или предложение";
|
||||
|
||||
"reports" = "Жалобы";
|
||||
|
||||
"support_rate_good_answer" = "Это хороший ответ";
|
||||
"support_rate_bad_answer" = "Это плохой ответ";
|
||||
"support_good_answer_user" = "Вы оставили положительный отзыв.";
|
||||
|
|
Loading…
Reference in a new issue