diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index a847d328..cc8e5393 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -2,7 +2,7 @@ namespace openvk\VKAPI\Handlers; use openvk\Web\Models\Entities\{User, Report}; use openvk\Web\Models\Repositories\Users as UsersRepo; -use openvk\Web\Models\Repositories\{Photos, Clubs, Albums, Videos, Notes, Audios, Blacklists}; +use openvk\Web\Models\Repositories\{Photos, Clubs, Albums, Videos, Notes, Audios}; use openvk\Web\Models\Repositories\Reports; final class Users extends VKAPIRequestHandler @@ -52,8 +52,8 @@ final class Users extends VKAPIRequestHandler "last_name" => $usr->getLastName(true), "is_closed" => $usr->isClosed(), "can_access_closed" => (bool)$usr->canBeViewedBy($this->getUser()), - "blacklisted" => (new Blacklists)->isBanned($usr, $authuser), - "blacklisted_by_me" => (new Blacklists)->isBanned($authuser, $usr) + "blacklisted" => false, + "blacklisted_by_me" => false, ]; $flds = explode(',', $fields); @@ -271,11 +271,10 @@ final class Users extends VKAPIRequestHandler } } - if (!(new Blacklists)->isBanned($usr, $authuser)) - if($usr->getOnline()->timestamp() + 300 > time()) - $response[$i]->online = 1; - else - $response[$i]->online = 0; + if($usr->getOnline()->timestamp() + 300 > time()) + $response[$i]->online = 1; + else + $response[$i]->online = 0; } } } @@ -309,7 +308,7 @@ final class Users extends VKAPIRequestHandler $response = $this->get(implode(',', $followers), $fields, 0, $count); return (object) [ - "count" => $target->getFollowersCount(), + "count" => $users->get($user_id)->getFollowersCount(), "items" => $response ]; } diff --git a/Web/Models/Entities/BlacklistItem.php b/Web/Models/Entities/BlacklistItem.php deleted file mode 100644 index fcc19452..00000000 --- a/Web/Models/Entities/BlacklistItem.php +++ /dev/null @@ -1,31 +0,0 @@ -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); - } -} \ No newline at end of file diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 34789f4f..45a54ecb 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -5,7 +5,7 @@ use openvk\Web\Themes\{Themepack, Themepacks}; use openvk\Web\Util\DateTime; use openvk\Web\Models\RowModel; use openvk\Web\Models\Entities\{Photo, Message, Correspondence, Gift, Audio}; -use openvk\Web\Models\Repositories\{Applications, Bans, Comments, Notes, Posts, Users, Clubs, Albums, Gifts, Notifications, Videos, Photos, Blacklists}; +use openvk\Web\Models\Repositories\{Applications, Bans, Comments, Notes, Posts, Users, Clubs, Albums, Gifts, Notifications, Videos, Photos}; use openvk\Web\Models\Exceptions\InvalidUserNameException; use Nette\Database\Table\ActiveRow; use Chandler\Database\DatabaseConnection; @@ -510,7 +510,7 @@ class User extends RowModel return $permStatus === User::PRIVACY_EVERYONE; else if($user->getId() === $this->getId()) return true; - else if ((new Blacklists)->isBanned($this, $user)) { + else if ($this->isBlacklistedBy($user)) { return $user->isAdmin() && !OPENVK_ROOT_CONF["openvk"]["preferences"]["security"]["blacklists"]["applyToAdmins"]; } @@ -1494,6 +1494,11 @@ class User extends RowModel return DatabaseConnection::i()->getContext()->table("ignored_sources")->where("owner", $this->getId())->count(); } + function isBlacklistedBy($user): bool + { + return false; + } + use Traits\TBackDrops; use Traits\TSubscribable; use Traits\TAudioStatuses; diff --git a/Web/Models/Repositories/Blacklists.php b/Web/Models/Repositories/Blacklists.php deleted file mode 100644 index f13534ef..00000000 --- a/Web/Models/Repositories/Blacklists.php +++ /dev/null @@ -1,46 +0,0 @@ -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 getByAuthorAndTarget(int $author, int $target): ?BlacklistItem - { - $fetch = $this->blacklists->where(["author" => $author, "target" => $target])->fetch(); - if ($fetch) - return new BlacklistItem($fetch); - else - return null; - } - - 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 !is_null($this->getByAuthorAndTarget($author->getId(), $target->getId())); - } -} diff --git a/Web/Presenters/BlacklistPresenter.php b/Web/Presenters/BlacklistPresenter.php deleted file mode 100644 index 37ed36ec..00000000 --- a/Web/Presenters/BlacklistPresenter.php +++ /dev/null @@ -1,43 +0,0 @@ -blacklists = $blacklists; - } - - function renderAddToBlacklist(): 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", tr("success"), tr("user_blacklisted", $target->getCanonicalName())); - } - - function renderRemoveFromBlacklist(): void - { - $this->willExecuteWriteAction(); - $this->assertUserLoggedIn(); - - $record = $this->blacklists->getByAuthorAndTarget($this->user->identity->getId(), $this->postParam("id")); - $name = $record->getTarget()->getCanonicalName(); - $record->delete(false); - - $this->flashFail("succ", tr("success"), tr("user_removed_from_the_blacklist", $name)); - } -} diff --git a/Web/Presenters/PhotosPresenter.php b/Web/Presenters/PhotosPresenter.php index f8524572..029d2aac 100644 --- a/Web/Presenters/PhotosPresenter.php +++ b/Web/Presenters/PhotosPresenter.php @@ -1,7 +1,7 @@ users = $users; - $this->blacklists = $blacklists; parent::__construct(); } @@ -581,7 +579,7 @@ final class UserPresenter extends OpenVKPresenter $this->flash("succ", tr("changes_saved"), tr("changes_saved_comment")); } $this->template->mode = in_array($this->queryParam("act"), [ - "main", "security", "privacy", "finance", "finance.top-up", "interface", "blacklist" + "main", "security", "privacy", "finance", "finance.top-up", "interface" ]) ? $this->queryParam("act") : "main"; @@ -595,11 +593,6 @@ final class UserPresenter extends OpenVKPresenter $this->template->qrCodeType = substr($qrCode[0], 5); $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->themes = Themepacks::i()->getThemeList(); diff --git a/Web/Presenters/VideosPresenter.php b/Web/Presenters/VideosPresenter.php index 58d60c43..dbf4efea 100644 --- a/Web/Presenters/VideosPresenter.php +++ b/Web/Presenters/VideosPresenter.php @@ -1,7 +1,7 @@
@@ -31,9 +30,6 @@
{_interface}
-
- {_blacklist} -
@@ -717,49 +713,6 @@ - - {elseif $isBlackList} - {if $count < 1} - {include "../components/nothing.xml"} - {/if} -
- - - - - - - - -
- - Фотография пользователя - - - - - {$item->getTarget()->getCanonicalName()} - - - -
- - - - - - - -
Дата добавления:{$item->getCreationDate()}
-
-
{/if}
diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index 79209624..10801053 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -171,19 +171,6 @@ {/if} {tr("followers", $user->getFollowersCount())} - {if $isBlacklistedThem} - - {else} - - {/if}
{var $completeness = $user->getProfileCompletenessReport()} @@ -399,11 +386,6 @@
-
- {_admin_privacy_warning}: -
- {_user_blacklisted_you} -
{strpos($alert, "@") === 0 ? tr(substr($alert, 1)) : $alert}
{var $thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()}