diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 40ef7aef..5a4fc2f4 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -348,10 +348,11 @@ class User extends RowModel return $this->getRecord()->marital_status; } - function getLocalizedMaritalStatus(): string + function getLocalizedMaritalStatus(?bool $prefix = false): string { $status = $this->getMaritalStatus(); $string = "relationship_$status"; + if ($prefix) $string .= "_prefix"; if($this->isFemale()) { $res = tr($string . "_fem"); if($res != ("@" . $string . "_fem")) @@ -361,6 +362,17 @@ class User extends RowModel return tr($string); } + function getMaritalStatusUser(): ?User + { + if (!$this->getRecord()->marital_status_user) return NULL; + return (new Users)->get($this->getRecord()->marital_status_user); + } + + function getMaritalStatusUserPrefix(): ?string + { + return $this->getLocalizedMaritalStatus(true); + } + function getContactEmail(): ?string { return $this->getRecord()->email_contact; diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 56d5685b..3097115f 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -166,6 +166,19 @@ final class UserPresenter extends OpenVKPresenter if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0) $user->setMarital_Status($this->postParam("marialstatus")); + + if ($this->postParam("maritalstatus-user")) { + if (in_array((int) $this->postParam("marialstatus"), [0, 1, 8])) { + $user->setMarital_Status_User(NULL); + } else { + $mUser = (new Users)->getByAddress($this->postParam("maritalstatus-user")); + if ($mUser) { + if ($mUser->getId() !== $this->user->id) { + $user->setMarital_Status_User($mUser->getId()); + } + } + } + } if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0) $user->setPolit_Views($this->postParam("politViews")); diff --git a/Web/Presenters/templates/User/Edit.xml b/Web/Presenters/templates/User/Edit.xml index 0a28b879..fef8a109 100644 --- a/Web/Presenters/templates/User/Edit.xml +++ b/Web/Presenters/templates/User/Edit.xml @@ -101,7 +101,7 @@ {_relationship}: -