mirror of
https://github.com/openvk/openvk
synced 2024-12-25 10:01:05 +03:00
upd
This commit is contained in:
parent
ae0258c78b
commit
82a5aaf8b8
6 changed files with 22 additions and 38 deletions
|
@ -22,6 +22,11 @@ class Blacklists
|
|||
yield new BlacklistItem($blacklistItem);
|
||||
}
|
||||
|
||||
function getByAuthorAndTarget(int $author, int $target): ?BlacklistItem
|
||||
{
|
||||
return new BlacklistItem($this->blacklists->where(["author" => $author, "target" => $target])->fetch());
|
||||
}
|
||||
|
||||
function getCount(User $user): int
|
||||
{
|
||||
return sizeof($this->blacklists->where("author", $user->getId())->fetch());
|
||||
|
@ -32,6 +37,6 @@ class Blacklists
|
|||
if (!$author || !$target)
|
||||
return FALSE;
|
||||
|
||||
return sizeof(DB::i()->getContext()->table("blacklists")->where(["author" => $author->getId(), "target" => $target->getId()])->fetch()) > 0;
|
||||
return !is_null($this->getByAuthorAndTarget($author->getId(), $target->getId()));
|
||||
}
|
||||
}
|
|
@ -34,9 +34,10 @@ final class BlacklistPresenter extends OpenVKPresenter
|
|||
$this->willExecuteWriteAction();
|
||||
$this->assertUserLoggedIn();
|
||||
|
||||
$record = new BlacklistItem(DB::i()->getContext()->table("blacklists")->where([ "author" => $this->user->identity->getId(), "target" => $this->postParam("id") ])->fetch());
|
||||
$record = $this->blacklists->getByAuthorAndTarget($this->user->identity->getId(), $this->postParam("id"));
|
||||
//$record = new BlacklistItem(DB::i()->getContext()->table("blacklists")->where([ "author" => $this->user->identity->getId(), "target" => ])->fetch());
|
||||
$name = $record->getTarget()->getCanonicalName();
|
||||
$record->delete(FALSE);
|
||||
$record->delete(false);
|
||||
|
||||
$this->flashFail("succ", "Успех", "$name удалён из чёрного списка.");
|
||||
}
|
||||
|
|
|
@ -18,12 +18,8 @@ final class NotesPresenter extends OpenVKPresenter
|
|||
{
|
||||
$user = (new Users)->get($owner);
|
||||
if(!$user) $this->notFound();
|
||||
if(!$user->getPrivacyPermission('notes.read', $this->user->identity ?? NULL)) {
|
||||
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
|
||||
if(!$user->getPrivacyPermission('notes.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
}
|
||||
|
||||
$this->template->notes = $this->notes->getUserNotes($user, (int)($this->queryParam("p") ?? 1));
|
||||
$this->template->count = $this->notes->getUserNotesCount($user);
|
||||
|
|
|
@ -24,12 +24,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
if($owner > 0) {
|
||||
$user = $this->users->get($owner);
|
||||
if(!$user) $this->notFound();
|
||||
if (!$user->getPrivacyPermission('photos.read', $this->user->identity ?? NULL)) {
|
||||
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
|
||||
if (!$user->getPrivacyPermission('photos.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
}
|
||||
|
||||
$this->template->albums = $this->albums->getUserAlbums($user, $this->queryParam("p") ?? 1);
|
||||
$this->template->count = $this->albums->getUserAlbumsCount($user);
|
||||
$this->template->owner = $user;
|
||||
|
@ -147,12 +144,8 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
|
||||
if($owner > 0 /* bc we currently don't have perms for clubs */) {
|
||||
$ownerObject = (new Users)->get($owner);
|
||||
if(!$ownerObject->getPrivacyPermission('photos.read', $this->user->identity ?? NULL)) {
|
||||
if ((new Blacklists)->isBanned($ownerObject, $this->user->identity))
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
|
||||
if(!$ownerObject->getPrivacyPermission('photos.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
}
|
||||
}
|
||||
|
||||
$this->template->album = $album;
|
||||
|
|
|
@ -34,8 +34,9 @@ final class UserPresenter extends OpenVKPresenter
|
|||
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"])
|
||||
if (OPENVK_ROOT_CONF["openvk"]["preferences"]["security"]["blacklists"]["applyToAdmins"]) {
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
}
|
||||
} else {
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
}
|
||||
|
@ -56,11 +57,11 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$this->template->videosCount = (new Videos)->getUserVideosCount($user);
|
||||
$this->template->notes = (new Notes)->getUserNotes($user, 1, 4);
|
||||
$this->template->notesCount = (new Notes)->getUserNotesCount($user);
|
||||
$this->template->blacklists = $this->blacklists;
|
||||
$this->template->blacklists = (new Blacklists);
|
||||
|
||||
$this->template->user = $user;
|
||||
$this->template->isBlacklistedThem = $this->blacklists->isBanned($this->user->identity, $user);
|
||||
$this->template->isBlacklistedByThem = $this->blacklists->isBanned($user, $this->user->identity);
|
||||
$this->template->isBlacklistedThem = $this->template->blacklists->isBanned($this->user->identity, $user);
|
||||
$this->template->isBlacklistedByThem = $this->template->blacklists->isBanned($user, $this->user->identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,12 +73,8 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$page = abs($this->queryParam("p") ?? 1);
|
||||
if(!$user)
|
||||
$this->notFound();
|
||||
elseif (!$user->getPrivacyPermission('friends.read', $this->user->identity ?? NULL)) {
|
||||
if ($this->blacklists->isBanned($user, $this->user->identity))
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
|
||||
elseif (!$user->getPrivacyPermission('friends.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
}
|
||||
else
|
||||
$this->template->user = $user;
|
||||
|
||||
|
@ -104,12 +101,8 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$user = $this->users->get($id);
|
||||
if(!$user)
|
||||
$this->notFound();
|
||||
elseif (!$user->getPrivacyPermission('groups.read', $this->user->identity ?? NULL)) {
|
||||
if ($this->blacklists->isBanned($user, $this->user->identity))
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
|
||||
elseif (!$user->getPrivacyPermission('groups.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
}
|
||||
else {
|
||||
if($this->queryParam("act") === "managed" && $this->user->id !== $user->getId())
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
|
|
|
@ -21,12 +21,8 @@ final class VideosPresenter extends OpenVKPresenter
|
|||
{
|
||||
$user = $this->users->get($id);
|
||||
if(!$user) $this->notFound();
|
||||
if(!$user->getPrivacyPermission('videos.read', $this->user->identity ?? NULL)) {
|
||||
if ((new Blacklists)->isBanned($user, $this->user->identity))
|
||||
$this->flashFail("err", tr("forbidden"), "Пользователь внёс Вас в чёрный список.");
|
||||
|
||||
if(!$user->getPrivacyPermission('videos.read', $this->user->identity ?? NULL))
|
||||
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
|
||||
}
|
||||
|
||||
$this->template->user = $user;
|
||||
$this->template->videos = $this->videos->getByUser($user, (int) ($this->queryParam("p") ?? 1));
|
||||
|
|
Loading…
Reference in a new issue