mirror of
https://github.com/openvk/openvk
synced 2024-11-14 19:19:14 +03:00
Отображение пользователей и удаленного контента
This commit is contained in:
parent
ee2e5e8d1c
commit
a9332823b1
13 changed files with 74 additions and 7 deletions
|
@ -93,4 +93,9 @@ class Album extends MediaCollection
|
|||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getURL(): string
|
||||
{
|
||||
return "/album" . $this->getPrettyId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,4 +138,9 @@ class Note extends Postable
|
|||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getURL(): string
|
||||
{
|
||||
return "/note" . $this->getPrettyId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,6 +245,11 @@ class Post extends Postable
|
|||
$this->unwire();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
function getURL(): string
|
||||
{
|
||||
return "/wall" . $this->getPrettyId();
|
||||
}
|
||||
|
||||
use Traits\TRichText;
|
||||
}
|
||||
|
|
|
@ -64,5 +64,10 @@ class Ticket extends RowModel
|
|||
return false;
|
||||
}
|
||||
|
||||
function getURL(): string
|
||||
{
|
||||
return "/support/reply/" . $this->getId();
|
||||
}
|
||||
|
||||
use Traits\TRichText;
|
||||
}
|
||||
|
|
|
@ -132,5 +132,10 @@ class TicketComment extends RowModel
|
|||
return (bool) $this->getRecord()->deleted;
|
||||
}
|
||||
|
||||
function getURL(): string
|
||||
{
|
||||
return "/support/reply/" . $this->getTicket()->getId();
|
||||
}
|
||||
|
||||
use Traits\TRichText;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php declare(strict_types=1);
|
||||
namespace openvk\Web\Models\Entities;
|
||||
use Chandler\Database\Logs;
|
||||
use openvk\Web\Models\Repositories\CurrentUser;
|
||||
use openvk\Web\Util\Shell\Shell;
|
||||
use openvk\Web\Util\Shell\Shell\Exceptions\{ShellUnavailableException, UnknownCommandException};
|
||||
use openvk\Web\Models\VideoDrivers\VideoDriver;
|
||||
|
@ -197,6 +199,7 @@ class Video extends Media
|
|||
|
||||
function deleteVideo(): void
|
||||
{
|
||||
(new Logs)->create(CurrentUser::i()->getUser()->getChandlerGUID(), "videos", get_class($this), 2, $this, ["deleted" => 1]);
|
||||
$this->setDeleted(1);
|
||||
$this->unwire();
|
||||
$this->save();
|
||||
|
|
|
@ -48,6 +48,11 @@ class Users
|
|||
{
|
||||
return $user ? $this->toUser($this->users->where("user", $user->getId())->fetch()) : NULL;
|
||||
}
|
||||
|
||||
function getByChandlerGUID(string $GUID): ?User
|
||||
{
|
||||
return $this->toUser($this->users->where("user", $GUID)->fetch());
|
||||
}
|
||||
|
||||
function find(string $query, array $pars = [], string $sort = "id DESC"): Util\EntityStream
|
||||
{
|
||||
|
|
|
@ -36,8 +36,11 @@ final class NotesPresenter extends OpenVKPresenter
|
|||
function renderView(int $owner, int $note_id): void
|
||||
{
|
||||
$note = $this->notes->getNoteById($owner, $note_id);
|
||||
if(!$note || $note->getOwner()->getId() !== $owner || $note->isDeleted())
|
||||
if(!$note || $note->getOwner()->getId() !== $owner)
|
||||
$this->notFound();
|
||||
|
||||
$this->assertCanViewDeleted($note);
|
||||
|
||||
if(!$note->getOwner()->getPrivacyPermission('notes.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use Chandler\Session\Session;
|
|||
use Chandler\Security\Authenticator;
|
||||
use Latte\Engine as TemplatingEngine;
|
||||
use openvk\Web\Models\Entities\IP;
|
||||
use openvk\Web\Models\RowModel;
|
||||
use openvk\Web\Themes\Themepacks;
|
||||
use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser};
|
||||
use WhichBrowser;
|
||||
|
@ -148,6 +149,19 @@ abstract class OpenVKPresenter extends SimplePresenter
|
|||
$this->flashFail("err", tr("rate_limit_error"), tr("rate_limit_error_comment", OPENVK_ROOT_CONF["openvk"]["appearance"]["name"], $res), NULL, $json);
|
||||
}
|
||||
}
|
||||
|
||||
protected function assertCanViewDeleted(RowModel $object): void
|
||||
{
|
||||
if ($object->isDeleted()) {
|
||||
if ($this->queryParam("del")) {
|
||||
if ($this->assertPermission("admin", "access", -1)) {
|
||||
$this->flash("warn", "Обратите внимание", "Вы просматриваете удаленный контент. Его видят только администраторы");
|
||||
}
|
||||
} else {
|
||||
$this->notFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function signal(object $event): bool
|
||||
{
|
||||
|
|
|
@ -134,8 +134,10 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
{
|
||||
$album = $this->albums->get($id);
|
||||
if(!$album) $this->notFound();
|
||||
if($album->getPrettyId() !== $owner . "_" . $id || $album->isDeleted())
|
||||
if($album->getPrettyId() !== $owner . "_" . $id)
|
||||
$this->notFound();
|
||||
|
||||
$this->assertCanViewDeleted($album);
|
||||
|
||||
if($owner > 0 /* bc we currently don't have perms for clubs */) {
|
||||
$ownerObject = (new Users)->get($owner);
|
||||
|
|
|
@ -203,9 +203,11 @@ final class SupportPresenter extends OpenVKPresenter
|
|||
$this->assertPermission('openvk\Web\Models\Entities\TicketReply', 'write', 0);
|
||||
$ticket = $this->tickets->get($id);
|
||||
|
||||
if(!$ticket || $ticket->isDeleted() != 0)
|
||||
if(!$ticket)
|
||||
$this->notFound();
|
||||
|
||||
$this->assertCanViewDeleted($ticket);
|
||||
|
||||
$ticketComments = $this->comments->getCommentsById($id);
|
||||
$this->template->ticket = $ticket;
|
||||
$this->template->comments = $ticketComments;
|
||||
|
|
|
@ -343,9 +343,11 @@ final class WallPresenter extends OpenVKPresenter
|
|||
function renderPost(int $wall, int $post_id): void
|
||||
{
|
||||
$post = $this->posts->getPostById($wall, $post_id);
|
||||
if(!$post || $post->isDeleted())
|
||||
if(!$post)
|
||||
$this->notFound();
|
||||
|
||||
|
||||
$this->assertCanViewDeleted($post);
|
||||
|
||||
$this->logPostView($post, $wall);
|
||||
|
||||
$this->template->post = $post;
|
||||
|
|
|
@ -53,7 +53,14 @@
|
|||
<tr n:foreach="$logs as $log">
|
||||
<td>{$log->getId()}</td>
|
||||
<td>
|
||||
<a href="/admin/chandler/user/{$log->getUser()}" target="_blank">{$log->getUser()}</a>
|
||||
{var $_user = (new openvk\Web\Models\Repositories\Users)->getByChandlerGUID($log->getUser())}
|
||||
<span n:if="$_user->getAvatarURL('miniscule')" class="aui-avatar aui-avatar-xsmall">
|
||||
<span class="aui-avatar-inner">
|
||||
<img src="{$_user->getAvatarURL()}" alt="{$_user->getCanonicalName()}"
|
||||
style="object-fit: cover;" role="presentation"/>
|
||||
</span>
|
||||
</span>
|
||||
<a href="/admin/users/id{$_user->getId()}">{$_user->getCanonicalName()}</a>
|
||||
</td>
|
||||
<td>
|
||||
<span n:if="$log->getObjectAvatar()" class="aui-avatar aui-avatar-xsmall">
|
||||
|
@ -61,7 +68,11 @@
|
|||
<img src="{$log->getObjectAvatar()}" alt="{$log->getObjectName()}" style="object-fit: cover;" role="presentation" />
|
||||
</span>
|
||||
</span>
|
||||
<a href="{$log->getObjectURL()}">{$log->getObjectName()}</a>
|
||||
<a
|
||||
n:attr="href => ($log->getObjectURL()) . (($log->getTypeRaw() === 2 && $log->getObjectURL() !== '#') ? '?del=1' : '')"
|
||||
>
|
||||
{$log->getObjectName()}
|
||||
</a>
|
||||
</td>
|
||||
<td>{_$log->getTypeNom()}</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in a new issue