mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Add ability to mention user in marital status (#947)
This commit is contained in:
parent
1f340e392f
commit
92435ae6a8
7 changed files with 75 additions and 14 deletions
|
@ -348,10 +348,11 @@ class User extends RowModel
|
||||||
return $this->getRecord()->marital_status;
|
return $this->getRecord()->marital_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLocalizedMaritalStatus(): string
|
function getLocalizedMaritalStatus(?bool $prefix = false): string
|
||||||
{
|
{
|
||||||
$status = $this->getMaritalStatus();
|
$status = $this->getMaritalStatus();
|
||||||
$string = "relationship_$status";
|
$string = "relationship_$status";
|
||||||
|
if ($prefix) $string .= "_prefix";
|
||||||
if($this->isFemale()) {
|
if($this->isFemale()) {
|
||||||
$res = tr($string . "_fem");
|
$res = tr($string . "_fem");
|
||||||
if($res != ("@" . $string . "_fem"))
|
if($res != ("@" . $string . "_fem"))
|
||||||
|
@ -361,6 +362,17 @@ class User extends RowModel
|
||||||
return tr($string);
|
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
|
function getContactEmail(): ?string
|
||||||
{
|
{
|
||||||
return $this->getRecord()->email_contact;
|
return $this->getRecord()->email_contact;
|
||||||
|
|
|
@ -167,6 +167,19 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
||||||
$user->setMarital_Status($this->postParam("marialstatus"));
|
$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)
|
if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0)
|
||||||
$user->setPolit_Views($this->postParam("politViews"));
|
$user->setPolit_Views($this->postParam("politViews"));
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
<span class="nobold">{_relationship}: </span>
|
<span class="nobold">{_relationship}: </span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="marialstatus">
|
<select name="marialstatus" onChange="toggleMaritalStatus(this)">
|
||||||
<option n:foreach="range(0, 8) as $i" n:attr="selected => ($user->getMaritalStatus() == $i)" value="{$i}">
|
<option n:foreach="range(0, 8) as $i" n:attr="selected => ($user->getMaritalStatus() == $i)" value="{$i}">
|
||||||
{if $user->isFemale()}
|
{if $user->isFemale()}
|
||||||
{var $str = "relationship_$i"}
|
{var $str = "relationship_$i"}
|
||||||
|
@ -117,23 +117,23 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr id="maritalstatus-user"
|
||||||
|
n:attr="style => $user->getMaritalStatusUser() || ($user->getMaritalStatus() && !in_array($user->getMaritalStatus(), [0, 1, 8])) ? '' : 'display: none;'">
|
||||||
|
<td width="120" valign="top"></td>
|
||||||
|
<td>
|
||||||
|
<input type="text" placeholder="{_page_address}" name="maritalstatus-user"
|
||||||
|
n:attr="value => $user->getMaritalStatusUser() ? $user->getMaritalStatusUser()->getId() : ''" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="120" valign="top">
|
<td width="120" valign="top">
|
||||||
<span class="nobold">{_politViews}: </span>
|
<span class="nobold">{_politViews}: </span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="politViews">
|
<select name="politViews">
|
||||||
<option value="0" {if $user->getPoliticalViews() == 0}selected{/if}>{_politViews_0}</option>
|
<option n:foreach="range(0, 9) as $i" n:attr="selected => ($user->getPoliticalViews() == $i)" value="{$i}">
|
||||||
<option value="1" {if $user->getPoliticalViews() == 1}selected{/if}>{_politViews_1}</option>
|
{tr("politViews_" . $i)}
|
||||||
<option value="2" {if $user->getPoliticalViews() == 2}selected{/if}>{_politViews_2}</option>
|
</option>
|
||||||
<option value="3" {if $user->getPoliticalViews() == 3}selected{/if}>{_politViews_3}</option>
|
|
||||||
<option value="4" {if $user->getPoliticalViews() == 4}selected{/if}>{_politViews_4}</option>
|
|
||||||
<option value="5" {if $user->getPoliticalViews() == 5}selected{/if}>{_politViews_5}</option>
|
|
||||||
<option value="6" {if $user->getPoliticalViews() == 6}selected{/if}>{_politViews_6}</option>
|
|
||||||
<option value="7" {if $user->getPoliticalViews() == 7}selected{/if}>{_politViews_7}</option>
|
|
||||||
<option value="8" {if $user->getPoliticalViews() == 8}selected{/if}>{_politViews_8}</option>
|
|
||||||
<option value="9" {if $user->getPoliticalViews() == 9}selected{/if}>{_politViews_9}</option>
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -178,6 +178,17 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<script>
|
||||||
|
function toggleMaritalStatus(e) {
|
||||||
|
let elem = $("#maritalstatus-user");
|
||||||
|
$("#maritalstatus-user-select").empty();
|
||||||
|
if ([0, 1, 8].includes(Number(e.value))) {
|
||||||
|
elem.hide();
|
||||||
|
} else {
|
||||||
|
elem.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{elseif $isContacts}
|
{elseif $isContacts}
|
||||||
|
|
|
@ -456,7 +456,15 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><span class="nobold">{_relationship}:</span></td>
|
<td class="label"><span class="nobold">{_relationship}:</span></td>
|
||||||
<td class="data">{$user->getLocalizedMaritalStatus()}</td>
|
<td class="data">
|
||||||
|
{$user->getLocalizedMaritalStatus()}
|
||||||
|
{if $user->getMaritalStatusUser()}
|
||||||
|
{$user->getMaritalStatusUserPrefix()}
|
||||||
|
<a href="{$user->getMaritalStatusUser()->getURL()}" target="_blank">
|
||||||
|
{$user->getMaritalStatusUser()->getCanonicalName()}
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><span class="nobold">{_registration_date}: </span></td>
|
<td class="label"><span class="nobold">{_registration_date}: </span></td>
|
||||||
|
|
2
install/sqls/00038-marital-status-user.sql
Normal file
2
install/sqls/00038-marital-status-user.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `profiles`
|
||||||
|
ADD `marital_status_user` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `marital_status`;
|
|
@ -113,6 +113,14 @@
|
||||||
"relationship_7" = "Everything is complicated";
|
"relationship_7" = "Everything is complicated";
|
||||||
"relationship_8" = "Actively searching";
|
"relationship_8" = "Actively searching";
|
||||||
|
|
||||||
|
/* xd */
|
||||||
|
"relationship_2_prefix" = "with";
|
||||||
|
"relationship_3_prefix" = "with";
|
||||||
|
"relationship_4_prefix" = "with";
|
||||||
|
"relationship_5_prefix" = "with";
|
||||||
|
"relationship_6_prefix" = "with";
|
||||||
|
"relationship_7_prefix" = "with";
|
||||||
|
|
||||||
"politViews" = "Polit. Views";
|
"politViews" = "Polit. Views";
|
||||||
|
|
||||||
"politViews_0" = "Not Selected";
|
"politViews_0" = "Not Selected";
|
||||||
|
|
|
@ -103,6 +103,13 @@
|
||||||
"relationship_3_fem" = "Помолвлена";
|
"relationship_3_fem" = "Помолвлена";
|
||||||
"relationship_4_fem" = "Замужем";
|
"relationship_4_fem" = "Замужем";
|
||||||
"relationship_6_fem" = "Влюблена";
|
"relationship_6_fem" = "Влюблена";
|
||||||
|
"relationship_2_prefix" = "с";
|
||||||
|
"relationship_3_prefix" = "с";
|
||||||
|
"relationship_4_prefix" = "на";
|
||||||
|
"relationship_4_prefix_fem" = "за";
|
||||||
|
"relationship_5_prefix" = "с";
|
||||||
|
"relationship_6_prefix" = "в";
|
||||||
|
"relationship_7_prefix" = "с";
|
||||||
"politViews" = "Полит. взгляды";
|
"politViews" = "Полит. взгляды";
|
||||||
"politViews_0" = "Не выбраны";
|
"politViews_0" = "Не выбраны";
|
||||||
"politViews_1" = "Индифферентные";
|
"politViews_1" = "Индифферентные";
|
||||||
|
|
Loading…
Reference in a new issue