diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index b09e82a55..a65dada83 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -377,6 +377,17 @@ public function get(string $user_ids = "0", string $fields = "", int $offset = 0 $response[$i]->bdate = null; } break; + case 'personal': + $response[$i]->personal = (object) [ + 'political' => $usr->getPoliticalViews(), + 'langs' => [], // FIXME: not implemented + 'inspired_by' => $usr->getInspires(), + 'people_main' => $usr->getMainInPeople(), + 'life_main' => $usr->getMainInLife(), + 'smoking' => $usr->getViewsOnSmoking(), + 'alcohol' => $usr->getViewsOnAlcohol(), + ]; + break; } } diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 819efdd40..d39bc26c9 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -42,6 +42,14 @@ class User extends RowModel public const NSFW_TOLERANT = 1; public const NSFW_FULL_TOLERANT = 2; + + public const PREFERENCES_COUNTS = [ + 'politViews' => 10, + 'mainInLife' => 9, + 'mainInPeople' => 7, + 'viewsOnSubstances' => 6, + ]; + /* aggressive caching */ private $_avatarAlbum = null; private $_avatarPhoto = false; // false - not resolved, null - no avatar @@ -414,6 +422,36 @@ public function getPoliticalViews(): int return $this->getRecord()->polit_views; } + public function getWorldview(): string + { + return $this->getRecord()->worldview; + } + + public function getMainInLife(): int + { + return $this->getRecord()->main_in_life; + } + + public function getMainInPeople(): int + { + return $this->getRecord()->main_in_people; + } + + public function getViewsOnSmoking(): int + { + return $this->getRecord()->views_on_smoking; + } + + public function getViewsOnAlcohol(): int + { + return $this->getRecord()->views_on_alcohol; + } + + public function getInspires(): string + { + return $this->getRecord()->inspires; + } + public function getMaritalStatus(): int { return $this->getRecord()->marital_status; @@ -530,6 +568,60 @@ public function getAdditionalFields(bool $split = false): array return $result; } + public function getPersonalInfo() + { + $info = []; + if ($this->getPoliticalViews() > 0) { + $info[] = [ + 'label' => tr('politViews'), + 'value' => tr('politViews_' . $this->getPoliticalViews()), + ]; + } + if ($this->getWorldview() != '') { + $info[] = [ + 'label' => tr('worldview'), + 'value' => $this->getWorldview(), + ]; + } + + if ($this->getMainInLife() > 0) { + $info[] = [ + 'label' => tr('mainInLife'), + 'value' => tr('mainInLife_' . $this->getMainInLife()), + ]; + } + + if ($this->getMainInPeople() > 0) { + $info[] = [ + 'label' => tr('mainInPeople'), + 'value' => tr('mainInPeople_' . $this->getMainInPeople()), + ]; + } + + if ($this->getViewsOnSmoking() > 0) { + $info[] = [ + 'label' => tr('viewsOnSmoking'), + 'value' => tr('viewsOnSubstances_' . $this->getViewsOnSmoking()), + ]; + } + + if ($this->getViewsOnAlcohol() > 0) { + $info[] = [ + 'label' => tr('viewsOnAlcohol'), + 'value' => tr('viewsOnSubstances_' . $this->getViewsOnAlcohol()), + ]; + } + + if ($this->getInspires() != '') { + $info[] = [ + 'label' => tr('inspires'), + 'value' => $this->getInspires(), + ]; + } + + return $info; + } + public function getNotificationOffset(): int { return $this->getRecord()->notification_offset; diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 4a7e759df..3c4149afa 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -7,7 +7,7 @@ use Nette\InvalidStateException; use openvk\Web\Util\Sms; use openvk\Web\Themes\Themepacks; -use openvk\Web\Models\Entities\{Photo, Post, EmailChangeVerification}; +use openvk\Web\Models\Entities\{Photo, Post, EmailChangeVerification, User}; use openvk\Web\Models\Entities\Notifications\{CoinsTransferNotification, RatingUpNotification}; use openvk\Web\Models\Repositories\{Users, Clubs, Albums, Videos, Notes, Vouchers, EmailChangeVerifications, Audios, Faves}; use openvk\Web\Models\Exceptions\InvalidUserNameException; @@ -195,11 +195,20 @@ public function renderEdit(): void $this->notFound(); } + + + $act = in_array($this->queryParam("act"), [ + "main", "contacts", "interests", "avatar", "backdrop", "additional", "personal", + ]) ? $this->queryParam("act") + : "main"; + + $this->template->mode = $act; + $user = $this->users->get($id); if ($_SERVER["REQUEST_METHOD"] === "POST") { $this->willExecuteWriteAction($_GET['act'] === "status"); - if ($_GET['act'] === "main" || $_GET['act'] == null) { + if ($act === "main" || $act == null) { try { $user->setFirst_Name(empty($this->postParam("first_name")) ? $user->getFirstName() : $this->postParam("first_name")); $user->setLast_Name(empty($this->postParam("last_name")) ? "" : $this->postParam("last_name")); @@ -239,10 +248,6 @@ public function renderEdit(): void } } - if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0) { - $user->setPolit_Views($this->postParam("politViews")); - } - if ($this->postParam("pronouns") <= 2 && $this->postParam("pronouns") >= 0) { switch ($this->postParam("pronouns")) { case '0': @@ -269,7 +274,26 @@ public function renderEdit(): void $this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!"); } } - } elseif ($_GET['act'] === "contacts") { + } elseif ($act === "personal") { + + if ($this->postParam("politViews") < User::PREFERENCES_COUNTS['politViews'] && $this->postParam("politViews") >= 0) { + $user->setPolit_Views($this->postParam("politViews")); + } + $user->setWorldview(mb_substr($this->postParam("worldview") ?? "", 0, 256)); + if ($this->postParam("mainInLife") < User::PREFERENCES_COUNTS['mainInLife'] && $this->postParam("mainInLife") >= 0) { + $user->setMain_In_Life($this->postParam("mainInLife")); + } + if ($this->postParam("mainInPeople") < User::PREFERENCES_COUNTS['mainInPeople'] && $this->postParam("mainInPeople") >= 0) { + $user->setMain_In_People($this->postParam("mainInPeople")); + } + if ($this->postParam("viewsOnSmoking") < User::PREFERENCES_COUNTS['viewsOnSubstances'] && $this->postParam("viewsOnSmoking") >= 0) { + $user->setViews_On_Smoking($this->postParam("viewsOnSmoking")); + } + if ($this->postParam("viewsOnAlcohol") < User::PREFERENCES_COUNTS['viewsOnSubstances'] && $this->postParam("viewsOnAlcohol") >= 0) { + $user->setViews_On_Alcohol($this->postParam("viewsOnAlcohol")); + } + $user->setInspires(mb_substr($this->postParam("inspires") ?? "", 0, 256)); + } elseif ($act === "contacts") { if (empty($this->postParam("email_contact")) || Validator::i()->emailValid($this->postParam("email_contact"))) { $user->setEmail_Contact(empty($this->postParam("email_contact")) ? null : $this->postParam("email_contact")); } else { @@ -296,7 +320,7 @@ public function renderEdit(): void } else { $user->setWebsite((!parse_url($website, PHP_URL_SCHEME) ? "https://" : "") . $website); } - } elseif ($_GET['act'] === "interests") { + } elseif ($act === "interests") { $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)); @@ -332,7 +356,7 @@ public function renderEdit(): void $user->setBackDropPictures($pic1, $pic2); $user->save(); $this->flashFail("succ", tr("backdrop_succ"), tr("backdrop_succ_desc")); - } elseif ($_GET['act'] === "status") { + } elseif ($act === "status") { if (mb_strlen($this->postParam("status")) > 255) { $statusLength = (string) mb_strlen($this->postParam("status")); $this->flashFail("err", tr("error"), tr("error_status_too_long", $statusLength), null, true); @@ -345,7 +369,7 @@ public function renderEdit(): void $this->returnJson([ "success" => true, ]); - } elseif ($_GET['act'] === "additional") { + } elseif ($act === "additional") { $maxAddFields = ovkGetQuirk("users.max-fields"); $items = []; @@ -382,7 +406,7 @@ public function renderEdit(): void } try { - if ($_GET['act'] !== "additional") { + if ($act !== "additional") { $user->save(); } } catch (\PDOException $ex) { @@ -396,11 +420,6 @@ public function renderEdit(): void $this->flash("succ", tr("changes_saved"), tr("changes_saved_comment")); } - $this->template->mode = in_array($this->queryParam("act"), [ - "main", "contacts", "interests", "avatar", "backdrop", "additional", - ]) ? $this->queryParam("act") - : "main"; - $this->template->user = $user; } diff --git a/Web/Presenters/templates/User/Edit.latte b/Web/Presenters/templates/User/Edit.latte index 5b721ea36..758683ee2 100644 --- a/Web/Presenters/templates/User/Edit.latte +++ b/Web/Presenters/templates/User/Edit.latte @@ -16,6 +16,7 @@ {var $isAdditional = $mode === 'additional'} {var $isAvatar = $mode === 'avatar'} {var $isBackDrop = $mode === 'backdrop'} + {var $isPersonal = $mode === 'personal'}
Подтверждение номера телефона
@@ -35,12 +36,16 @@
{_additional}
+
+ {_personal} +
{_avatar}
{_backdrop_short}
+
@@ -129,18 +134,6 @@ n:attr="value => $user->getMaritalStatusUser() ? $user->getMaritalStatusUser()->getURL(true) : ''" /> - - - {_politViews}: - - - - - {_pronouns}: @@ -327,6 +320,101 @@ + {elseif $isPersonal} + +

{_personal}

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {_politViews}: + + +
+ {_worldview}: + + +
+ {_mainInLife}: + + +
+ {_mainInPeople}: + + +
+ {_viewsOnSmoking}: + + +
+ {_viewsOnAlcohol}: + + +
+ {_inspires}: + + +
+ + + + +
+
+ {elseif $isAvatar}

{_profile_picture}

diff --git a/Web/Presenters/templates/User/View.latte b/Web/Presenters/templates/User/View.latte index 5f2389a98..761a05520 100644 --- a/Web/Presenters/templates/User/View.latte +++ b/Web/Presenters/templates/User/View.latte @@ -4,47 +4,47 @@ {var $backdrops = $user->getBackDropPictureURLs()} {/if} -{block title}{$user->getCanonicalName()}{/block} +{block title}{$user->getCanonicalName()}{/block} {block headIncludes} {if $user->getPrivacyPermission('page.read', $thisUser ?? NULL)} - {var $ogDescription = $user->getStatus() ?? $user->getDescription() ?? ''} - {var $ogDescriptionTrimmed = mb_strlen($ogDescription) > 200 ? mb_substr($ogDescription, 0, 197) . '...' : $ogDescription} - {var $avatarUrl = $user->getAvatarUrl('normal')} - - - - - - - - - - - - - - - {else} - + } + + {else} + {/if} {/block} {block header} {$user->getCanonicalName()} + class="name-checkmark" + src="/assets/packages/static/openvk/img/checkmark.png" + /> ({_this_is_you}) - +
{if $user->isOnline()} @@ -65,708 +65,721 @@ {block content} {if !$user->isBanned()} - - {if !$user->getPrivacyPermission('page.read', $thisUser ?? NULL)} -
- {_forbidden}
- {_forbidden_comment} -
- {else} - -
-
- {var $hasAvatar = !str_contains($user->getAvatarUrl('miniscule'), "/assets/packages/static/openvk/img/camera_200.png")} - + + {if !$user->getPrivacyPermission('page.read', $thisUser ?? NULL)} +
+ {_forbidden}
+ {_forbidden_comment} +
+ {else} + +
+
+ {var $hasAvatar = !str_contains($user->getAvatarUrl('miniscule'), "/assets/packages/static/openvk/img/camera_200.png")} + {if $thisUser && $user->getId() == $thisUser->getId()} - - {/if} - - {$user->getCanonicalName()} - -
- + -
- {var $completeness = $user->getProfileCompletenessReport()} - + + {if $thisUser->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)} + + {_manage_user_action} + + + {_ban_user_action} + + + {_warn_user_action} + + + {_blocks} + + + {_last_actions} + + {/if} + + {if $thisUser->getChandlerUser()->can('write')->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)} + + {if $user->isBannedInSupport()} + {_unban_in_support_user_action} + {else} + {_ban_in_support_user_action} + {/if} + + {/if} + + {_send_gift} + {_send_message} + + {var $subStatus = $user->getSubscriptionStatus($thisUser)} + {if $subStatus === 0} + + {elseif $subStatus === 1} + + {elseif $subStatus === 2} + + {elseif $subStatus === 3} + + {/if} + + {_bl_add} + {* 4 admins *} + {_bl_remove} + {_report} + + {if !$ignore_status}{_ignore_user}{else}{_unignore_user}{/if} + + {/if} + {tr("followers", $user->getFollowersCount())} +
+
+ {var $completeness = $user->getProfileCompletenessReport()} +
-
- {$completeness->total}% +
+ {$completeness->total}%
- + {if isset($thisUser) && $user->getId() === $thisUser->getId() && sizeof($completeness->unfilled) > 0} -
- - - {_interests} (+20%) - - - - Email (+20%) - - - - {_phone} (+20%) - - - - Telegram (+15%) - - - - {_status} (+15%) - - {/if} -
-
-
- {var $friendCount = $user->getFriendsCount()} - -
- {_friends} -
-
- -
-
-
- - - +
+
+ {var $friendCount = $user->getFriendsCount()} + +
+ {_friends} +
+
-
-
-
- {var $friendOnlineCount = $user->getFriendsOnlineCount()} - -
- {_friends_online} -
-
-
- {tr("friends_online", $friendOnlineCount)} -
- {_all_title} +
+ {var $friendOnlineCount = $user->getFriendsOnlineCount()} + +
+ {_friends_online}
-
- -
-
- {_albums} -
-
-
- {tr("albums", $albumsCount)} -
- {_all_title} +
+
+ {_albums}
-
-
-
-
- {var $cover = $album->getCoverPhoto()} - - +
+
+ {tr("albums", $albumsCount)} +
-
- {$album->getName()}
- {tr("updated_at", $album->getEditTime() ?? $album->getPublicationTime())} +
+
+
+ {var $cover = $album->getCoverPhoto()} + + +
+
+ {$album->getName()}
+ {tr("updated_at", $album->getEditTime() ?? $album->getPublicationTime())} +
+
-
-
-
-
- {_videos} -
-
-
- {tr("videos", $videosCount)} -
- {_all_title} +
+
+ {_videos}
-
-
-
- - - -
- {ovk_proc_strtr($video->getName(), 30)}
- {$video->getPublicationTime()} | {_comments} ({$video->getCommentsCount()}) +
+
+ {tr("videos", $videosCount)} + +
+
+
+ + + +
+ {ovk_proc_strtr($video->getName(), 30)}
+ {$video->getPublicationTime()} | {_comments} ({$video->getCommentsCount()}) +
+
-
-
-
-
- {_notes} -
-
-
- {tr("notes", $notesCount)} - -
- -
- -
-
-
-
- {var $clubsCount = $user->getClubCount()} -
- {_groups} -
-
-
- {tr("groups", $clubsCount)} -
- {_all_title} +
+
+ {_notes}
-
-
-
- {$club->getName()} {if !$iterator->last}•{/if} +
+
+ {tr("notes", $notesCount)} + +
+ +
+ +
-
-
-
- {var $meetingCount = $user->getEventsCount()} -
- {_meetings} -
-
-
- {tr("meetings", $meetingCount)} -
- {_all_title} +
+ {var $clubsCount = $user->getClubCount()} +
+ {_groups}
-
-
-
- {$meeting->getName()} {if !$iterator->last}•{/if} +
+
+ {tr("groups", $clubsCount)} + +
+
+
+ {$club->getName()} {if !$iterator->last}•{/if} +
+
-
-
- -
- -
-
-
{strpos($alert, "@") === 0 ? tr(substr($alert, 1)) : $alert}
- {var $thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()} -