diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index 4f1b59a4..6c31e9be 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -62,7 +62,7 @@ final class Users extends VKAPIRequestHandler $response[$i]->verified = intval($usr->isVerified()); break; case "sex": - $response[$i]->sex = $usr->isFemale() ? 1 : 2; + $response[$i]->sex = $usr->isFemale() ? 1 : ($usr->isNeutral() ? 0 : 2); break; case "has_photo": $response[$i]->has_photo = is_null($usr->getAvatarPhoto()) ? 0 : 1; diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index 527fb9a5..ba61247f 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -236,7 +236,7 @@ final class Wall extends VKAPIRequestHandler "last_name" => $user->getLastName(), "can_access_closed" => false, "is_closed" => false, - "sex" => $user->isFemale() ? 1 : 2, + "sex" => $user->isFemale() ? 1 : ($user->isNeutral() ? 0 : 2), "screen_name" => $user->getShortCode(), "photo_50" => $user->getAvatarUrl(), "photo_100" => $user->getAvatarUrl(), @@ -441,7 +441,7 @@ final class Wall extends VKAPIRequestHandler "last_name" => $user->getLastName(), "can_access_closed" => false, "is_closed" => false, - "sex" => $user->isFemale() ? 1 : 2, + "sex" => $user->isFemale() ? 1 : ($user->isNeutral() ? 0 : 2), "screen_name" => $user->getShortCode(), "photo_50" => $user->getAvatarUrl(), "photo_100" => $user->getAvatarUrl(), diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 5a4fc2f4..05de73ee 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -795,7 +795,29 @@ class User extends RowModel function isFemale(): bool { - return (bool) $this->getRecord()->sex; + return $this->getRecord()->sex == 1; + } + + function isNeutral(): bool + { + return (bool) $this->getRecord()->sex == 2; + } + + function getLocalizedPronouns(): string + { + switch ($this->getRecord()->sex) { + case 0: + return tr('male'); + case 1: + return tr('female'); + case 2: + return tr('neutral'); + } + } + + function getPronouns(): int + { + return $this->getRecord()->sex; } function isVerified(): bool diff --git a/Web/Presenters/AuthPresenter.php b/Web/Presenters/AuthPresenter.php index c6a7f143..7edcda7c 100644 --- a/Web/Presenters/AuthPresenter.php +++ b/Web/Presenters/AuthPresenter.php @@ -95,7 +95,17 @@ final class AuthPresenter extends OpenVKPresenter $user = new User; $user->setFirst_Name($this->postParam("first_name")); $user->setLast_Name($this->postParam("last_name")); - $user->setSex((int)($this->postParam("sex") === "female")); + switch ($this->postParam("pronouns")) { + case 'male': + $user->setSex(0); + break; + case 'female': + $user->setSex(1); + break; + case 'neutral': + $user->setSex(2); + break; + } $user->setEmail($this->postParam("email")); $user->setSince(date("Y-m-d H:i:s")); $user->setRegistering_Ip(CONNECTING_IP); diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 3097115f..870e4ab2 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -183,8 +183,18 @@ final class UserPresenter extends OpenVKPresenter if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0) $user->setPolit_Views($this->postParam("politViews")); - if ($this->postParam("gender") <= 1 && $this->postParam("gender") >= 0) - $user->setSex($this->postParam("gender")); + if ($this->postParam("pronouns") <= 2 && $this->postParam("pronouns") >= 0) + switch ($this->postParam("pronouns")) { + case '0': + $user->setSex(0); + break; + case '1': + $user->setSex(1); + break; + case '2': + $user->setSex(2); + break; + } $user->setAudio_broadcast_enabled($this->checkbox("broadcast_music")); if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) { diff --git a/Web/Presenters/templates/Auth/Register.xml b/Web/Presenters/templates/Auth/Register.xml index 23857633..120c0b91 100644 --- a/Web/Presenters/templates/Auth/Register.xml +++ b/Web/Presenters/templates/Auth/Register.xml @@ -91,13 +91,13 @@
{_gender}: | -{$user->isFemale() ? tr("female") : tr("male")} | +{_pronouns}: | +{$user->isFemale() ? tr("female") : ($user->isNeutral() ? tr("neutral") : tr("male"))} |
{_relationship}: | diff --git a/Web/Presenters/templates/components/post/microblogpost.xml b/Web/Presenters/templates/components/post/microblogpost.xml index 0b0978bc..04731619 100644 --- a/Web/Presenters/templates/components/post/microblogpost.xml +++ b/Web/Presenters/templates/components/post/microblogpost.xml @@ -26,8 +26,8 @@