From 996108289c17796018e7afe7953526430e59d057 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:13:05 +0300 Subject: [PATCH] add fav games --- VKAPI/Handlers/Account.php | 2 +- VKAPI/Handlers/Users.php | 15 ++++++++++++++- Web/Models/Entities/User.php | 8 ++++++++ Web/Presenters/UserPresenter.php | 15 ++++++++------- Web/Presenters/templates/User/Edit.xml | 8 ++++++++ Web/Presenters/templates/User/View.xml | 4 ++++ Web/static/js/al_wall.js | 3 ++- install/sqls/00053-new-fields.sql | 1 + locales/en.strings | 1 + locales/ru.strings | 1 + 10 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 install/sqls/00053-new-fields.sql diff --git a/VKAPI/Handlers/Account.php b/VKAPI/Handlers/Account.php index c1f3ef23..3f25df35 100644 --- a/VKAPI/Handlers/Account.php +++ b/VKAPI/Handlers/Account.php @@ -269,7 +269,7 @@ final class Account extends VKAPIRequestHandler return 1; $entity = get_entity_by_id($owner_id); - if(!$entity || $entity->isDeleted()) + if(!$entity) return 0; if(!$entity->isBlacklistedBy($this->getUser())) diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index 7dc68f3b..bbb78a55 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -12,8 +12,14 @@ final class Users extends VKAPIRequestHandler if($authuser == NULL) $authuser = $this->getUser(); $users = new UsersRepo; - if($user_ids == "0") + if($user_ids == "0") { + if(!$authuser) { + return []; + } + $user_ids = (string) $authuser->getId(); + } + $usrs = explode(',', $user_ids); $response = array(); @@ -198,6 +204,13 @@ final class Users extends VKAPIRequestHandler $response[$i]->quotes = $usr->getFavoriteQuote(); break; + case "games": + if(!$canView) { + break; + } + + $response[$i]->games = $usr->getFavoriteGames(); + break; case "email": if(!$canView) { break; diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 61ea120b..43290424 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -415,6 +415,11 @@ class User extends RowModel return $this->getRecord()->fav_quote; } + function getFavoriteGames(): ?string + { + return $this->getRecord()->fav_games; + } + function getCity(): ?string { return $this->getRecord()->city; @@ -1432,6 +1437,9 @@ class User extends RowModel $res->blacklisted = (int)$user->isBlacklistedBy($this); break; + case "games": + $res->games = $this->getFavoriteGames(); + break; } } diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index f238e381..556d5e8c 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -251,13 +251,14 @@ final class UserPresenter extends OpenVKPresenter else $user->setWebsite((!parse_url($website, PHP_URL_SCHEME) ? "https://" : "") . $website); } elseif($_GET['act'] === "interests") { - $user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 300)); - $user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 300)); - $user->setFav_Films(empty($this->postParam("fav_films")) ? NULL : ovk_proc_strtr($this->postParam("fav_films"), 300)); - $user->setFav_Shows(empty($this->postParam("fav_shows")) ? NULL : ovk_proc_strtr($this->postParam("fav_shows"), 300)); - $user->setFav_Books(empty($this->postParam("fav_books")) ? NULL : ovk_proc_strtr($this->postParam("fav_books"), 300)); - $user->setFav_Quote(empty($this->postParam("fav_quote")) ? NULL : ovk_proc_strtr($this->postParam("fav_quote"), 300)); - $user->setAbout(empty($this->postParam("about")) ? NULL : ovk_proc_strtr($this->postParam("about"), 300)); + $user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 1000)); + $user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 1000)); + $user->setFav_Films(empty($this->postParam("fav_films")) ? NULL : ovk_proc_strtr($this->postParam("fav_films"), 1000)); + $user->setFav_Shows(empty($this->postParam("fav_shows")) ? NULL : ovk_proc_strtr($this->postParam("fav_shows"), 1000)); + $user->setFav_Books(empty($this->postParam("fav_books")) ? NULL : ovk_proc_strtr($this->postParam("fav_books"), 1000)); + $user->setFav_Quote(empty($this->postParam("fav_quote")) ? NULL : ovk_proc_strtr($this->postParam("fav_quote"), 1000)); + $user->setFav_Games(empty($this->postParam("fav_games")) ? NULL : ovk_proc_strtr($this->postParam("fav_games"), 1000)); + $user->setAbout(empty($this->postParam("about")) ? NULL : ovk_proc_strtr($this->postParam("about"), 1000)); } elseif($_GET["act"] === "backdrop") { if($this->postParam("subact") === "remove") { $user->unsetBackDropPictures(); diff --git a/Web/Presenters/templates/User/Edit.xml b/Web/Presenters/templates/User/Edit.xml index 8bea7f0c..b0eea51f 100644 --- a/Web/Presenters/templates/User/Edit.xml +++ b/Web/Presenters/templates/User/Edit.xml @@ -294,6 +294,14 @@ +