mirror of
https://github.com/openvk/openvk
synced 2024-11-15 11:39:13 +03:00
Blacklist
This commit is contained in:
parent
4891030ed0
commit
aaad80f4f8
12 changed files with 255 additions and 17 deletions
31
Web/Models/Entities/BlacklistItem.php
Normal file
31
Web/Models/Entities/BlacklistItem.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
namespace openvk\Web\Models\Entities;
|
||||||
|
use openvk\Web\Models\RowModel;
|
||||||
|
use openvk\Web\Util\DateTime;
|
||||||
|
use openvk\Web\Models\Entities\{User, Manager};
|
||||||
|
use openvk\Web\Models\Repositories\{Users, Clubs};
|
||||||
|
|
||||||
|
class BlacklistItem extends RowModel
|
||||||
|
{
|
||||||
|
protected $tableName = "blacklists";
|
||||||
|
|
||||||
|
function getId(): int
|
||||||
|
{
|
||||||
|
return $this->getRecord()->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAuthor(): ?User
|
||||||
|
{
|
||||||
|
return (new Users)->get($this->getRecord()->author);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTarget(): ?User
|
||||||
|
{
|
||||||
|
return (new Users)->get($this->getRecord()->target);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCreationDate(): DateTime
|
||||||
|
{
|
||||||
|
return new DateTime($this->getRecord()->created);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ use openvk\Web\Themes\{Themepack, Themepacks};
|
||||||
use openvk\Web\Util\DateTime;
|
use openvk\Web\Util\DateTime;
|
||||||
use openvk\Web\Models\RowModel;
|
use openvk\Web\Models\RowModel;
|
||||||
use openvk\Web\Models\Entities\{Photo, Message, Correspondence, Gift};
|
use openvk\Web\Models\Entities\{Photo, Message, Correspondence, Gift};
|
||||||
use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Gifts, Notifications};
|
use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Gifts, Notifications, Blacklists};
|
||||||
use openvk\Web\Models\Exceptions\InvalidUserNameException;
|
use openvk\Web\Models\Exceptions\InvalidUserNameException;
|
||||||
use Nette\Database\Table\ActiveRow;
|
use Nette\Database\Table\ActiveRow;
|
||||||
use Chandler\Database\DatabaseConnection;
|
use Chandler\Database\DatabaseConnection;
|
||||||
|
@ -438,6 +438,12 @@ class User extends RowModel
|
||||||
return $permStatus === User::PRIVACY_EVERYONE;
|
return $permStatus === User::PRIVACY_EVERYONE;
|
||||||
else if($user->getId() === $this->getId())
|
else if($user->getId() === $this->getId())
|
||||||
return true;
|
return true;
|
||||||
|
else if ((new Blacklists)->isBanned($this, $user)) {
|
||||||
|
if ($user->isAdmin())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch($permStatus) {
|
switch($permStatus) {
|
||||||
case User::PRIVACY_ONLY_FRIENDS:
|
case User::PRIVACY_ONLY_FRIENDS:
|
||||||
|
@ -1018,5 +1024,10 @@ class User extends RowModel
|
||||||
return (bool) $this->getRecord()->activated;
|
return (bool) $this->getRecord()->activated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAdmin(): bool
|
||||||
|
{
|
||||||
|
return $this->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
use Traits\TSubscribable;
|
use Traits\TSubscribable;
|
||||||
}
|
}
|
||||||
|
|
37
Web/Models/Repositories/Blacklists.php
Normal file
37
Web/Models/Repositories/Blacklists.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
namespace openvk\Web\Models\Repositories;
|
||||||
|
use openvk\Web\Models\Entities\{User, BlacklistItem};
|
||||||
|
use openvk\Web\Models\Repositories\{Clubs, Users};
|
||||||
|
use Nette\Database\Table\ActiveRow;
|
||||||
|
use Chandler\Database\DatabaseConnection as DB;
|
||||||
|
|
||||||
|
class Blacklists
|
||||||
|
{
|
||||||
|
private $context;
|
||||||
|
private $blacklists;
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->context = DB::i()->getContext();
|
||||||
|
$this->blacklists = $this->context->table("blacklists");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getList(User $user, $page = 1): \Traversable
|
||||||
|
{
|
||||||
|
foreach($this->blacklists->where("author", $user->getId())->order("created DESC")->page($page, 10) as $blacklistItem)
|
||||||
|
yield new BlacklistItem($blacklistItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCount(User $user): int
|
||||||
|
{
|
||||||
|
return sizeof($this->blacklists->where("author", $user->getId())->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBanned(User $author, User $target): bool
|
||||||
|
{
|
||||||
|
if (!$author || !$target)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return sizeof(DB::i()->getContext()->table("blacklists")->where(["author" => $author->getId(), "target" => $target->getId()])->fetch()) > 0;
|
||||||
|
}
|
||||||
|
}
|
43
Web/Presenters/BlacklistPresenter.php
Normal file
43
Web/Presenters/BlacklistPresenter.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?php declare(strict_types=1);
|
||||||
|
namespace openvk\Web\Presenters;
|
||||||
|
use openvk\Web\Models\Entities\{BlacklistItem};
|
||||||
|
use openvk\Web\Models\Repositories\{Blacklists, Users};
|
||||||
|
use Chandler\Database\DatabaseConnection as DB;
|
||||||
|
|
||||||
|
final class BlacklistPresenter extends OpenVKPresenter
|
||||||
|
{
|
||||||
|
private $blacklists;
|
||||||
|
|
||||||
|
function __construct(Blacklists $blacklists)
|
||||||
|
{
|
||||||
|
$this->blacklists = $blacklists;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderAddToBl(): void
|
||||||
|
{
|
||||||
|
$this->willExecuteWriteAction();
|
||||||
|
$this->assertUserLoggedIn();
|
||||||
|
|
||||||
|
$record = new BlacklistItem;
|
||||||
|
$target = (new Users)->get((int) $this->postParam("id"));
|
||||||
|
|
||||||
|
$record->setAuthor($this->user->identity->getId());
|
||||||
|
$record->setTarget($this->postParam("id"));
|
||||||
|
$record->setCreated(time());
|
||||||
|
$record->save();
|
||||||
|
|
||||||
|
$this->flashFail("succ", "Успех", $target->getCanonicalName() . " занесён в чёрный список.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderRemoveFromBl(): void
|
||||||
|
{
|
||||||
|
$this->willExecuteWriteAction();
|
||||||
|
$this->assertUserLoggedIn();
|
||||||
|
|
||||||
|
$record = new BlacklistItem(DB::i()->getContext()->table("blacklists")->where([ "author" => $this->user->identity->getId(), "target" => $this->postParam("id") ])->fetch());
|
||||||
|
$name = $record->getTarget()->getCanonicalName();
|
||||||
|
$record->delete(FALSE);
|
||||||
|
|
||||||
|
$this->flashFail("succ", "Успех", "$name удалён из чёрного списка.");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
namespace openvk\Web\Presenters;
|
namespace openvk\Web\Presenters;
|
||||||
use openvk\Web\Models\Repositories\{Users, Notes};
|
use openvk\Web\Models\Repositories\{Users, Notes, Blacklists};
|
||||||
use openvk\Web\Models\Entities\Note;
|
use openvk\Web\Models\Entities\Note;
|
||||||
|
|
||||||
final class NotesPresenter extends OpenVKPresenter
|
final class NotesPresenter extends OpenVKPresenter
|
||||||
|
@ -18,8 +18,12 @@ final class NotesPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
$user = (new Users)->get($owner);
|
$user = (new Users)->get($owner);
|
||||||
if(!$user) $this->notFound();
|
if(!$user) $this->notFound();
|
||||||
if(!$user->getPrivacyPermission('notes.read', $this->user->identity ?? NULL))
|
if(!$user->getPrivacyPermission('notes.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->notes = $this->notes->getUserNotes($user, (int)($this->queryParam("p") ?? 1));
|
$this->template->notes = $this->notes->getUserNotes($user, (int)($this->queryParam("p") ?? 1));
|
||||||
$this->template->count = $this->notes->getUserNotesCount($user);
|
$this->template->count = $this->notes->getUserNotesCount($user);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
namespace openvk\Web\Presenters;
|
namespace openvk\Web\Presenters;
|
||||||
use openvk\Web\Models\Entities\{Club, Photo, Album};
|
use openvk\Web\Models\Entities\{Club, Photo, Album};
|
||||||
use openvk\Web\Models\Repositories\{Photos, Albums, Users, Clubs};
|
use openvk\Web\Models\Repositories\{Photos, Albums, Users, Clubs, Blacklists};
|
||||||
use Nette\InvalidStateException as ISE;
|
use Nette\InvalidStateException as ISE;
|
||||||
|
|
||||||
final class PhotosPresenter extends OpenVKPresenter
|
final class PhotosPresenter extends OpenVKPresenter
|
||||||
|
@ -24,8 +24,12 @@ final class PhotosPresenter extends OpenVKPresenter
|
||||||
if($owner > 0) {
|
if($owner > 0) {
|
||||||
$user = $this->users->get($owner);
|
$user = $this->users->get($owner);
|
||||||
if(!$user) $this->notFound();
|
if(!$user) $this->notFound();
|
||||||
if (!$user->getPrivacyPermission('photos.read', $this->user->identity ?? NULL))
|
if (!$user->getPrivacyPermission('photos.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
}
|
||||||
$this->template->albums = $this->albums->getUserAlbums($user, $this->queryParam("p") ?? 1);
|
$this->template->albums = $this->albums->getUserAlbums($user, $this->queryParam("p") ?? 1);
|
||||||
$this->template->count = $this->albums->getUserAlbumsCount($user);
|
$this->template->count = $this->albums->getUserAlbumsCount($user);
|
||||||
$this->template->owner = $user;
|
$this->template->owner = $user;
|
||||||
|
@ -138,9 +142,13 @@ final class PhotosPresenter extends OpenVKPresenter
|
||||||
|
|
||||||
if($owner > 0 /* bc we currently don't have perms for clubs */) {
|
if($owner > 0 /* bc we currently don't have perms for clubs */) {
|
||||||
$ownerObject = (new Users)->get($owner);
|
$ownerObject = (new Users)->get($owner);
|
||||||
if(!$ownerObject->getPrivacyPermission('photos.read', $this->user->identity ?? NULL))
|
if(!$ownerObject->getPrivacyPermission('photos.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ((new Blacklists)->isBanned($ownerObject, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->album = $album;
|
$this->template->album = $album;
|
||||||
$this->template->photos = iterator_to_array( $album->getPhotos( (int) ($this->queryParam("p") ?? 1), 20) );
|
$this->template->photos = iterator_to_array( $album->getPhotos( (int) ($this->queryParam("p") ?? 1), 20) );
|
||||||
|
@ -158,6 +166,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
||||||
$photo = $this->photos->getByOwnerAndVID($ownerId, $photoId);
|
$photo = $this->photos->getByOwnerAndVID($ownerId, $photoId);
|
||||||
if(!$photo || $photo->isDeleted()) $this->notFound();
|
if(!$photo || $photo->isDeleted()) $this->notFound();
|
||||||
|
|
||||||
|
if ((new Blacklists)->isBanned($photo->getOwner(), $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
if(!is_null($this->queryParam("from"))) {
|
if(!is_null($this->queryParam("from"))) {
|
||||||
if(preg_match("%^album([0-9]++)$%", $this->queryParam("from"), $matches) === 1) {
|
if(preg_match("%^album([0-9]++)$%", $this->queryParam("from"), $matches) === 1) {
|
||||||
$album = $this->albums->get((int) $matches[1]);
|
$album = $this->albums->get((int) $matches[1]);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use openvk\Web\Util\Sms;
|
||||||
use openvk\Web\Themes\Themepacks;
|
use openvk\Web\Themes\Themepacks;
|
||||||
use openvk\Web\Models\Entities\{Photo, Post, EmailChangeVerification};
|
use openvk\Web\Models\Entities\{Photo, Post, EmailChangeVerification};
|
||||||
use openvk\Web\Models\Entities\Notifications\{CoinsTransferNotification, RatingUpNotification};
|
use openvk\Web\Models\Entities\Notifications\{CoinsTransferNotification, RatingUpNotification};
|
||||||
use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Videos, Notes, Vouchers, EmailChangeVerifications};
|
use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Videos, Notes, Vouchers, EmailChangeVerifications, Blacklists};
|
||||||
use openvk\Web\Models\Exceptions\InvalidUserNameException;
|
use openvk\Web\Models\Exceptions\InvalidUserNameException;
|
||||||
use openvk\Web\Util\Validator;
|
use openvk\Web\Util\Validator;
|
||||||
use Chandler\Security\Authenticator;
|
use Chandler\Security\Authenticator;
|
||||||
|
@ -15,12 +15,14 @@ use Nette\Database\UniqueConstraintViolationException;
|
||||||
final class UserPresenter extends OpenVKPresenter
|
final class UserPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
private $users;
|
private $users;
|
||||||
|
private $blacklists;
|
||||||
|
|
||||||
public $deactivationTolerant = false;
|
public $deactivationTolerant = false;
|
||||||
|
|
||||||
function __construct(Users $users)
|
function __construct(Users $users, Blacklists $blacklists)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
|
$this->blacklists = $blacklists;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +30,11 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
function renderView(int $id): void
|
function renderView(int $id): void
|
||||||
{
|
{
|
||||||
$user = $this->users->get($id);
|
$user = $this->users->get($id);
|
||||||
|
|
||||||
|
if ($this->user->identity)
|
||||||
|
if ($this->blacklists->isBanned($user, $this->user->identity) && !$this->user->identity->isAdmin())
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
if(!$user || $user->isDeleted()) {
|
if(!$user || $user->isDeleted()) {
|
||||||
if($user->isDeactivated()) {
|
if($user->isDeactivated()) {
|
||||||
$this->template->_template = "User/deactivated.xml";
|
$this->template->_template = "User/deactivated.xml";
|
||||||
|
@ -43,8 +50,11 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
$this->template->videosCount = (new Videos)->getUserVideosCount($user);
|
$this->template->videosCount = (new Videos)->getUserVideosCount($user);
|
||||||
$this->template->notes = (new Notes)->getUserNotes($user, 1, 4);
|
$this->template->notes = (new Notes)->getUserNotes($user, 1, 4);
|
||||||
$this->template->notesCount = (new Notes)->getUserNotesCount($user);
|
$this->template->notesCount = (new Notes)->getUserNotesCount($user);
|
||||||
|
$this->template->blacklists = $this->blacklists;
|
||||||
|
|
||||||
$this->template->user = $user;
|
$this->template->user = $user;
|
||||||
|
$this->template->isBlacklistedThem = $this->blacklists->isBanned($this->user->identity, $user);
|
||||||
|
$this->template->isBlacklistedByThem = $this->blacklists->isBanned($user, $this->user->identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +66,12 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
$page = abs($this->queryParam("p") ?? 1);
|
$page = abs($this->queryParam("p") ?? 1);
|
||||||
if(!$user)
|
if(!$user)
|
||||||
$this->notFound();
|
$this->notFound();
|
||||||
elseif (!$user->getPrivacyPermission('friends.read', $this->user->identity ?? NULL))
|
elseif (!$user->getPrivacyPermission('friends.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ($this->blacklists->isBanned($user, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$this->template->user = $user;
|
$this->template->user = $user;
|
||||||
|
|
||||||
|
@ -84,8 +98,12 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
$user = $this->users->get($id);
|
$user = $this->users->get($id);
|
||||||
if(!$user)
|
if(!$user)
|
||||||
$this->notFound();
|
$this->notFound();
|
||||||
elseif (!$user->getPrivacyPermission('groups.read', $this->user->identity ?? NULL))
|
elseif (!$user->getPrivacyPermission('groups.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ($this->blacklists->isBanned($user, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if($this->queryParam("act") === "managed" && $this->user->id !== $user->getId())
|
if($this->queryParam("act") === "managed" && $this->user->id !== $user->getId())
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
@ -454,7 +472,7 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
|
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
|
||||||
}
|
}
|
||||||
$this->template->mode = in_array($this->queryParam("act"), [
|
$this->template->mode = in_array($this->queryParam("act"), [
|
||||||
"main", "privacy", "finance", "finance.top-up", "interface"
|
"main", "privacy", "finance", "finance.top-up", "interface", "blacklist"
|
||||||
]) ? $this->queryParam("act")
|
]) ? $this->queryParam("act")
|
||||||
: "main";
|
: "main";
|
||||||
|
|
||||||
|
@ -469,6 +487,11 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
$this->template->qrCodeData = $qrCode[1];
|
$this->template->qrCodeData = $qrCode[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->template->mode == "blacklist") {
|
||||||
|
$this->template->items = $this->blacklists->getList($user);
|
||||||
|
$this->template->count = $this->blacklists->getCount($user);
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->user = $user;
|
$this->template->user = $user;
|
||||||
$this->template->themes = Themepacks::i()->getThemeList();
|
$this->template->themes = Themepacks::i()->getThemeList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
namespace openvk\Web\Presenters;
|
namespace openvk\Web\Presenters;
|
||||||
use openvk\Web\Models\Entities\Video;
|
use openvk\Web\Models\Entities\Video;
|
||||||
use openvk\Web\Models\Repositories\{Users, Videos};
|
use openvk\Web\Models\Repositories\{Users, Videos, Blacklists};
|
||||||
use Nette\InvalidStateException as ISE;
|
use Nette\InvalidStateException as ISE;
|
||||||
|
|
||||||
final class VideosPresenter extends OpenVKPresenter
|
final class VideosPresenter extends OpenVKPresenter
|
||||||
|
@ -21,8 +21,12 @@ final class VideosPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
$user = $this->users->get($id);
|
$user = $this->users->get($id);
|
||||||
if(!$user) $this->notFound();
|
if(!$user) $this->notFound();
|
||||||
if(!$user->getPrivacyPermission('videos.read', $this->user->identity ?? NULL))
|
if(!$user->getPrivacyPermission('videos.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->user = $user;
|
$this->template->user = $user;
|
||||||
$this->template->videos = $this->videos->getByUser($user, (int) ($this->queryParam("p") ?? 1));
|
$this->template->videos = $this->videos->getByUser($user, (int) ($this->queryParam("p") ?? 1));
|
||||||
|
@ -39,8 +43,12 @@ final class VideosPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
$user = $this->users->get($owner);
|
$user = $this->users->get($owner);
|
||||||
if(!$user) $this->notFound();
|
if(!$user) $this->notFound();
|
||||||
if(!$user->getPrivacyPermission('videos.read', $this->user->identity ?? NULL))
|
if(!$user->getPrivacyPermission('videos.read', $this->user->identity ?? NULL)) {
|
||||||
|
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||||
|
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||||
|
|
||||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||||
|
}
|
||||||
|
|
||||||
if($this->videos->getByOwnerAndVID($owner, $vId)->isDeleted()) $this->notFound();
|
if($this->videos->getByOwnerAndVID($owner, $vId)->isDeleted()) $this->notFound();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
{var $isFinance = $mode === 'finance'}
|
{var $isFinance = $mode === 'finance'}
|
||||||
{var $isFinanceTU = $mode === 'finance.top-up'}
|
{var $isFinanceTU = $mode === 'finance.top-up'}
|
||||||
{var $isInterface = $mode === 'interface'}
|
{var $isInterface = $mode === 'interface'}
|
||||||
|
{var $isBlackList = $mode === 'blacklist'}
|
||||||
|
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<div n:attr="id => ($isMain ? 'activetabs' : 'ki')" class="tab">
|
<div n:attr="id => ($isMain ? 'activetabs' : 'ki')" class="tab">
|
||||||
|
@ -26,6 +27,9 @@
|
||||||
<div n:attr="id => ($isInterface ? 'activetabs' : 'ki')" class="tab">
|
<div n:attr="id => ($isInterface ? 'activetabs' : 'ki')" class="tab">
|
||||||
<a n:attr="id => ($isInterface ? 'act_tab_a' : 'ki')" href="/settings?act=interface">{_interface}</a>
|
<a n:attr="id => ($isInterface ? 'act_tab_a' : 'ki')" href="/settings?act=interface">{_interface}</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div n:attr="id => ($isBlackList ? 'activetabs' : 'ki')" class="tab">
|
||||||
|
<a n:attr="id => ($isBlackList ? 'act_tab_a' : 'ki')" href="/settings?act=blacklist">Чёрный список</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container_gray">
|
<div class="container_gray">
|
||||||
|
@ -656,6 +660,48 @@
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{elseif $isBlackList}
|
||||||
|
{if $count < 1}
|
||||||
|
{include "../components/nothing.xml"}
|
||||||
|
{/if}
|
||||||
|
<div n:foreach="$items as $item" class="content">
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">
|
||||||
|
<a href="/id2">
|
||||||
|
<img src="{$item->getTarget()->getAvatarURL()}" width="75" alt="Фотография пользователя">
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td valign="top" style="width: 100%">
|
||||||
|
<a href="/id2">
|
||||||
|
<b>
|
||||||
|
{$item->getTarget()->getCanonicalName()}
|
||||||
|
<img n:if="$item->getTarget()->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">
|
||||||
|
</b>
|
||||||
|
</a>
|
||||||
|
<br>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width="120" valign="top"><span class="nobold">Дата добавления:</span></td>
|
||||||
|
<td>{$item->getCreationDate()}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td valign="top" class="action_links" style="width: 150px;">
|
||||||
|
<form action="/removeFromBl" method="post" class="profile_link_form">
|
||||||
|
<input type="hidden" name="act" value="rem">
|
||||||
|
<input type="hidden" name="id" value="{$item->getTarget()->getId()}">
|
||||||
|
<input type="hidden" name="hash" value="{$csrfToken}">
|
||||||
|
<input type="submit" class="profile_link" value="удалить из чёрного списка">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,19 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<a n:if="$user->getFollowersCount() > 0" href="/friends{$user->getId()}?act=incoming" class="profile_link">{tr("followers", $user->getFollowersCount())}</a>
|
<a n:if="$user->getFollowersCount() > 0" href="/friends{$user->getId()}?act=incoming" class="profile_link">{tr("followers", $user->getFollowersCount())}</a>
|
||||||
|
{if $isBlacklistedThem}
|
||||||
|
<form n:if="$thisUser->getId() != $user->getId()" action="/removeFromBl" method="post" class="profile_link_form">
|
||||||
|
<input type="hidden" name="id" value="{$user->getId()}" />
|
||||||
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
|
<input type="submit" class="profile_link" value="Удалить из чёрного списка" />
|
||||||
|
</form>
|
||||||
|
{else}
|
||||||
|
<form n:if="$thisUser->getId() != $user->getId()" action="/addToBl" method="post" class="profile_link_form">
|
||||||
|
<input type="hidden" name="id" value="{$user->getId()}" />
|
||||||
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
|
<input type="submit" class="profile_link" value="Добавить в чёрный список" />
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div n:if="isset($thisUser) && !$thisUser->prefersNotToSeeRating()" class="profile-hints">
|
<div n:if="isset($thisUser) && !$thisUser->prefersNotToSeeRating()" class="profile-hints">
|
||||||
{var $completeness = $user->getProfileCompletenessReport()}
|
{var $completeness = $user->getProfileCompletenessReport()}
|
||||||
|
@ -354,6 +367,11 @@
|
||||||
|
|
||||||
<div class="right_big_block">
|
<div class="right_big_block">
|
||||||
<div class="page_info">
|
<div class="page_info">
|
||||||
|
<div n:if="$isBlacklistedByThem AND $thisUser->isAdmin() AND $thisUser->getId() !== $user->getId()" class="user-alert">
|
||||||
|
<b>Будьте осторожны с этой информацией:</b>
|
||||||
|
<br/>
|
||||||
|
Пользователь внёс Вас в чёрный список
|
||||||
|
</div>
|
||||||
<div n:if="!is_null($alert = $user->getAlert())" class="user-alert">{strpos($alert, "@") === 0 ? tr(substr($alert, 1)) : $alert}</div>
|
<div n:if="!is_null($alert = $user->getAlert())" class="user-alert">{strpos($alert, "@") === 0 ? tr(substr($alert, 1)) : $alert}</div>
|
||||||
{var $thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()}
|
{var $thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()}
|
||||||
<div n:if="$thatIsThisUser" class="page_status_popup" id="status_editor" style="display: none;">
|
<div n:if="$thatIsThisUser" class="page_status_popup" id="status_editor" style="display: none;">
|
||||||
|
|
|
@ -23,6 +23,7 @@ services:
|
||||||
- openvk\Web\Presenters\AppsPresenter
|
- openvk\Web\Presenters\AppsPresenter
|
||||||
- openvk\Web\Presenters\ThemepacksPresenter
|
- openvk\Web\Presenters\ThemepacksPresenter
|
||||||
- openvk\Web\Presenters\VKAPIPresenter
|
- openvk\Web\Presenters\VKAPIPresenter
|
||||||
|
- openvk\Web\Presenters\BlacklistPresenter
|
||||||
- openvk\Web\Models\Repositories\Users
|
- openvk\Web\Models\Repositories\Users
|
||||||
- openvk\Web\Models\Repositories\Posts
|
- openvk\Web\Models\Repositories\Posts
|
||||||
- openvk\Web\Models\Repositories\Photos
|
- openvk\Web\Models\Repositories\Photos
|
||||||
|
@ -42,3 +43,4 @@ services:
|
||||||
- openvk\Web\Models\Repositories\Topics
|
- openvk\Web\Models\Repositories\Topics
|
||||||
- openvk\Web\Models\Repositories\Applications
|
- openvk\Web\Models\Repositories\Applications
|
||||||
- openvk\Web\Models\Repositories\ContentSearchRepository
|
- openvk\Web\Models\Repositories\ContentSearchRepository
|
||||||
|
- openvk\Web\Models\Repositories\Blacklists
|
|
@ -97,6 +97,10 @@ routes:
|
||||||
handler: "Group->sub"
|
handler: "Group->sub"
|
||||||
- url: "/setSub/v4/club"
|
- url: "/setSub/v4/club"
|
||||||
handler: "Group->attend"
|
handler: "Group->attend"
|
||||||
|
- url: "/removeFromBl"
|
||||||
|
handler: "Blacklist->removeFromBl"
|
||||||
|
- url: "/addToBl"
|
||||||
|
handler: "Blacklist->addToBl"
|
||||||
- url: "/groups/{num}/setNewOwner/{num}"
|
- url: "/groups/{num}/setNewOwner/{num}"
|
||||||
handler: "Group->changeOwner"
|
handler: "Group->changeOwner"
|
||||||
- url: "/comment{num}/like"
|
- url: "/comment{num}/like"
|
||||||
|
|
Loading…
Reference in a new issue