diff --git a/Web/Models/Entities/BlacklistItem.php b/Web/Models/Entities/BlacklistItem.php index fcc194523..cf1477987 100644 --- a/Web/Models/Entities/BlacklistItem.php +++ b/Web/Models/Entities/BlacklistItem.php @@ -28,4 +28,6 @@ function getCreationDate(): DateTime { return new DateTime($this->getRecord()->created); } + + } \ No newline at end of file diff --git a/Web/Models/Repositories/Blacklists.php b/Web/Models/Repositories/Blacklists.php index 66cce946b..50fb9d703 100644 --- a/Web/Models/Repositories/Blacklists.php +++ b/Web/Models/Repositories/Blacklists.php @@ -24,7 +24,11 @@ function getList(User $user, $page = 1): \Traversable function getByAuthorAndTarget(int $author, int $target): ?BlacklistItem { - return new BlacklistItem($this->blacklists->where(["author" => $author, "target" => $target])->fetch()); + $fetch = $this->blacklists->where(["author" => $author, "target" => $target])->fetch(); + if ($fetch) + return new BlacklistItem($fetch); + else + return null; } function getCount(User $user): int @@ -37,6 +41,9 @@ function isBanned(User $author, User $target): bool if (!$author || !$target) return FALSE; + bdump($this->getByAuthorAndTarget($author->getId(), $target->getId()), "хуита какая-то вроде для бл*клиста"); + + return !is_null($this->getByAuthorAndTarget($author->getId(), $target->getId())); } } diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 4eca5038e..3dd4c9d0d 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -34,14 +34,14 @@ function renderView(int $id): void if ($this->user->identity) if ($this->blacklists->isBanned($user, $this->user->identity)) { - if ($this->user->identity->isAdmin()) { - if (OPENVK_ROOT_CONF["openvk"]["preferences"]["security"]["blacklists"]["applyToAdmins"]) { - $this->flashFail("err", tr("forbidden"), tr("user_blacklisted_you")); - } - } else { + if ($this->user->identity->isAdmin()) { + if (OPENVK_ROOT_CONF["openvk"]["preferences"]["security"]["blacklists"]["applyToAdmins"]) { $this->flashFail("err", tr("forbidden"), tr("user_blacklisted_you")); } + } else { + $this->flashFail("err", tr("forbidden"), tr("user_blacklisted_you")); } + } if(!$user || $user->isDeleted()) { if(!is_null($user) && $user->isDeactivated()) { diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index 9ab1a1eb3..295825cbd 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -394,7 +394,7 @@