From 39cd4fe217263da154b29811538eeeab1e2f1b1b Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:50:24 +0300 Subject: [PATCH] rewrite ui --- VKAPI/Handlers/Users.php | 16 +++++++- Web/Models/Entities/User.php | 16 +++++++- Web/Presenters/GroupPresenter.php | 2 +- Web/Presenters/UserPresenter.php | 22 ++++++++++- Web/Presenters/templates/User/Settings.xml | 27 +++++++++++++ Web/Presenters/templates/User/View.xml | 1 + Web/Presenters/templates/User/blacklisted.xml | 37 ++++++++++++++++++ .../templates/User/blacklisted_pov.xml | 37 ++++++++++++++++++ Web/static/css/main.css | 14 +++++++ Web/static/js/al_wall.js | 39 +++++++++++++++++++ Web/static/js/router.js | 4 ++ locales/en.strings | 15 +++++++ locales/ru.strings | 15 +++++++ 13 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 Web/Presenters/templates/User/blacklisted.xml create mode 100644 Web/Presenters/templates/User/blacklisted_pov.xml diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index cc8e5393..7dc68f3b 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -52,8 +52,6 @@ final class Users extends VKAPIRequestHandler "last_name" => $usr->getLastName(true), "is_closed" => $usr->isClosed(), "can_access_closed" => (bool)$usr->canBeViewedBy($this->getUser()), - "blacklisted" => false, - "blacklisted_by_me" => false, ]; $flds = explode(',', $fields); @@ -268,6 +266,20 @@ final class Users extends VKAPIRequestHandler case 'nickname': $response[$i]->nickname = $usr->getPseudo(); break; + case 'blacklisted_by_me': + if(!$authuser) { + continue; + } + + $response[$i]->blacklisted_by_me = (int)$usr->isBlacklistedBy($this->getUser()); + break; + case 'blacklisted': + if(!$authuser) { + continue; + } + + $response[$i]->blacklisted = (int)$this->getUser()->isBlacklistedBy($usr); + break; } } diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 03b2fe5f..c74a2538 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -511,7 +511,7 @@ class User extends RowModel else if($user->getId() === $this->getId()) return true; - if($permission != "messages.write" && !$this->canBeViewedBy($user)) + if(/*$permission != "messages.write" && */!$this->canBeViewedBy($user, true)) return false; switch($permStatus) { @@ -1301,7 +1301,7 @@ class User extends RowModel return true; } - if($user->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)) { + if($user->isAdmin() && !(OPENVK_ROOT_CONF['openvk']['preferences']['blacklists']['applyToAdmins'] ?? true)) { return true; } @@ -1517,6 +1517,18 @@ class User extends RowModel "target" => $user->getRealId(), "created" => time(), ]); + + DatabaseConnection::i()->getContext()->table("subscriptions")->where([ + "follower" => $user->getId(), + "model" => static::class, + "target" => $this->getId(), + ])->delete(); + + DatabaseConnection::i()->getContext()->table("subscriptions")->where([ + "follower" => $this->getId(), + "model" => static::class, + "target" => $user->getId(), + ])->delete(); return true; } diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 61b6d67c..fd0e9a3d 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -119,7 +119,7 @@ final class GroupPresenter extends OpenVKPresenter $this->template->paginatorConf = (object) [ "count" => $this->template->count, "page" => $this->queryParam("p") ?? 1, - "amount" => NULL, + "amount" => 10, "perPage" => OPENVK_DEFAULT_PER_PAGE, ]; } diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 0f617f9b..e253f4bb 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -34,6 +34,12 @@ final class UserPresenter extends OpenVKPresenter if(!is_null($user) && $user->isDeactivated()) { $this->template->_template = "User/deactivated.xml"; + $this->template->user = $user; + } else if($user->isBlacklistedBy($this->user->identity)) { + $this->template->_template = "User/blacklisted_pov.xml"; + $this->template->user = $user; + } else if($this->user->identity->isBlacklistedBy($user)) { + $this->template->_template = "User/blacklisted.xml"; $this->template->user = $user; } else if(!is_null($user) && !$user->canBeViewedBy($this->user->identity)) { $this->template->_template = "User/private.xml"; @@ -58,6 +64,7 @@ final class UserPresenter extends OpenVKPresenter if($id !== $this->user->id) { $this->template->ignore_status = $user->isIgnoredBy($this->user->identity); + $this->template->blacklist_status = $user->isBlacklistedBy($this->user->identity); } } } @@ -579,7 +586,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" + "main", "security", "privacy", "finance", "finance.top-up", "interface", "blacklist" ]) ? $this->queryParam("act") : "main"; @@ -592,6 +599,19 @@ final class UserPresenter extends OpenVKPresenter $this->template->qrCodeType = substr($qrCode[0], 5); $this->template->qrCodeData = $qrCode[1]; + } else if($this->template->mode === "blacklist") { + $page = (int)($this->queryParam('p') ?? 1); + $count = 10; + $offset = ($page - 1) * $count; + + $this->template->blSize = $this->user->identity->getBlacklistSize(); + $this->template->blItems = $this->user->identity->getBlacklist($offset, $count); + $this->template->paginatorConf = (object) [ + "count" => $this->template->blSize, + "page" => $page, + "amount" => sizeof($this->template->blItems), + "perPage" => OPENVK_DEFAULT_PER_PAGE, + ]; } $this->template->user = $user; diff --git a/Web/Presenters/templates/User/Settings.xml b/Web/Presenters/templates/User/Settings.xml index 9e9f091b..e7f4b5ac 100644 --- a/Web/Presenters/templates/User/Settings.xml +++ b/Web/Presenters/templates/User/Settings.xml @@ -13,6 +13,7 @@ {var $isFinance = $mode === 'finance'} {var $isFinanceTU = $mode === 'finance.top-up'} {var $isInterface = $mode === 'interface'} +{var $isBl = $mode === 'blacklist'}