Added other gender options (#312)

This commit is contained in:
n1rwana 2022-09-08 16:18:24 +03:00
parent e28964c813
commit 2e031fb482
9 changed files with 73 additions and 8 deletions

14
.idea/deployment.xml Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData">
<serverData>
<paths name="sftp://176.126.103.81:9482">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

7
.idea/discord.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>

View file

@ -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

View file

@ -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"), "котлетки");

View file

@ -133,11 +133,23 @@
<td width="120" valign="top">
<span class="nobold">{_gender}: </span>
</td>
<script>
function genderChanged(e) {
if(e.target.value == "other")
$('#other-gender-input').show('slide', 0, 1000)
else
$('#other-gender-input').hide('slide', 0, 1000);
}
</script>
<td>
<select name="gender">
<option value="1" {if $user->isFemale() == true}selected{/if}>{_female}</option>
<option value="0" {if $user->isFemale() == false}selected{/if}>{_male}</option>
<select name="gender" onchange="genderChanged(event)">
<option value="hide" n:attr="selected => $user->getRawGender() == NULL">{_hide}</option>
<option value="female" n:attr="selected => $user->getRawGender() == 'female'">{_female}</option>
<option value="male" n:attr="selected => $user->getRawGender() == 'male'">{_male}</option>
<option value="non-binary" n:attr="selected => $user->getRawGender() == 'non-binary'">{_non-binary}</option>
<option value="other" n:attr="selected => $user->hasOtherGenderString()">{_other}</option>
</select>
<input id="other-gender-input" type="text" name="other-gender-string" placeholder="{_other_gender_placeholder}" style="display: {$user->hasOtherGenderString() ? 'inline' : 'none'};" />
</td>
</tr>
<tr>

View file

@ -382,7 +382,7 @@
<tbody>
<tr>
<td class="label"><span class="nobold">{_gender}: </span></td>
<td class="data">{$user->isFemale() ? tr("female") : tr("male")}</td>
<td class="data">{$user->getGender()}</td>
</tr>
<tr>
<td class="label"><span class="nobold">{_relationship}:</span></td>

View file

@ -0,0 +1,3 @@
ALTER TABLE `profiles` DROP `sex`
ALTER TABLE `profiles` ADD `gender` VARCHAR(50) NULL DEFAULT NULL AFTER `left_menu`;

View file

@ -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";

View file

@ -71,6 +71,9 @@
"gender" = "Пол";
"male" = "мужской";
"female" = "женский";
"non-binary" = "небинарный";
"other" = "другой";
"other_gender_placeholder" = "Я идентифицирую себя как...";
"description" = "Описание";
"save" = "Сохранить";
"main_information" = "Основная информация";