diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 00000000..dc2a86a5 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 00000000..30bab2ab --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 115bf8c2..74852869 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -723,7 +723,25 @@ class User extends RowModel function isFemale(): bool { - return (bool) $this->getRecord()->sex; + return (bool) $this->getRawGender() == "female"; + } + + function getGender(): string + { + $gender = $this->getRecord()->gender; + + if(in_array($gender, ["female", "male", "non-binary"])) return tr($gender); + else return $gender ?? "Не указан"; + } + + function getRawGender(): ?string + { + return $this->getRecord()->gender; + } + + function hasOtherGenderString(): bool + { + return !in_array($this->getRecord()->gender, ["female", "male", "non-binary", NULL]); } function isVerified(): bool diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index bfda79e8..029466af 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -164,9 +164,14 @@ 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("gender")) + if($this->postParam("gender") == "hide") + $user->setGender(NULL); + elseif($this->postParam("gender") == "other" && $this->postParam("other-gender-string")) + $user->setGender($this->postParam("other-gender-string")); + else + $user->setGender($this->postParam("gender")); + if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) { if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]["enable"]) $this->flashFail("err", tr("error_segmentation"), "котлетки"); diff --git a/Web/Presenters/templates/User/Edit.xml b/Web/Presenters/templates/User/Edit.xml index 96152132..f5e537ad 100644 --- a/Web/Presenters/templates/User/Edit.xml +++ b/Web/Presenters/templates/User/Edit.xml @@ -133,11 +133,23 @@ {_gender}: + - + + + + + + diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index fb38133d..571575a0 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -382,7 +382,7 @@ {_gender}: - {$user->isFemale() ? tr("female") : tr("male")} + {$user->getGender()} {_relationship}: diff --git a/install/sqls/00032-other-gender-options.sql b/install/sqls/00032-other-gender-options.sql new file mode 100644 index 00000000..3e10c739 --- /dev/null +++ b/install/sqls/00032-other-gender-options.sql @@ -0,0 +1,3 @@ +ALTER TABLE `profiles` DROP `sex` + +ALTER TABLE `profiles` ADD `gender` VARCHAR(50) NULL DEFAULT NULL AFTER `left_menu`; diff --git a/locales/en.strings b/locales/en.strings index 2e3461b7..bb5abb1e 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -69,6 +69,9 @@ "gender" = "Gender"; "male" = "male"; "female" = "female"; +"non-binary" = "non-binary"; +"other" = "other"; +"other_gender_placeholder" = "I refer to myself as..."; "description" = "Description"; "save" = "Save"; "main_information" = "Main information"; diff --git a/locales/ru.strings b/locales/ru.strings index 68f6d69f..cd142ec5 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -71,6 +71,9 @@ "gender" = "Пол"; "male" = "мужской"; "female" = "женский"; +"non-binary" = "небинарный"; +"other" = "другой"; +"other_gender_placeholder" = "Я идентифицирую себя как..."; "description" = "Описание"; "save" = "Сохранить"; "main_information" = "Основная информация";