mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Users: Improve the birthday field
Now you can hide the year of birth. Also people who were born on January 1, 1970 can specify their date of birth
This commit is contained in:
parent
e9cc9286ff
commit
5b5d095121
9 changed files with 34 additions and 10 deletions
|
@ -364,7 +364,15 @@ class User extends RowModel
|
|||
|
||||
function getBirthday(): ?DateTime
|
||||
{
|
||||
return new DateTime($this->getRecord()->birthday);
|
||||
if(is_null($this->getRecord()->birthday))
|
||||
return NULL;
|
||||
else
|
||||
return new DateTime($this->getRecord()->birthday);
|
||||
}
|
||||
|
||||
function getBirthdayPrivacy(): int
|
||||
{
|
||||
return $this->getRecord()->birthday_privacy;
|
||||
}
|
||||
|
||||
function getAge(): ?int
|
||||
|
|
|
@ -97,7 +97,7 @@ final class AuthPresenter extends OpenVKPresenter
|
|||
$user->setEmail($this->postParam("email"));
|
||||
$user->setSince(date("Y-m-d H:i:s"));
|
||||
$user->setRegistering_Ip(CONNECTING_IP);
|
||||
$user->setBirthday(strtotime($this->postParam("birthday")));
|
||||
$user->setBirthday(empty($this->postParam("birthday")) ? NULL : strtotime($this->postParam("birthday")));
|
||||
$user->setActivated((int)!OPENVK_ROOT_CONF['openvk']['preferences']['security']['requireEmail']);
|
||||
} catch(InvalidUserNameException $ex) {
|
||||
$this->flashFail("err", tr("error"), tr("invalid_real_name"));
|
||||
|
|
|
@ -157,7 +157,10 @@ final class UserPresenter extends OpenVKPresenter
|
|||
|
||||
|
||||
if (strtotime($this->postParam("birthday")) < time())
|
||||
$user->setBirthday(strtotime($this->postParam("birthday")));
|
||||
$user->setBirthday(empty($this->postParam("birthday")) ? NULL : strtotime($this->postParam("birthday")));
|
||||
|
||||
if ($this->postParam("birthday_privacy") <= 1 && $this->postParam("birthday_privacy") >= 0)
|
||||
$user->setBirthday_Privacy($this->postParam("birthday_privacy"));
|
||||
|
||||
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
||||
$user->setMarital_Status($this->postParam("marialstatus"));
|
||||
|
|
|
@ -145,7 +145,11 @@
|
|||
<span class="nobold">{_"birth_date"}: </span>
|
||||
</td>
|
||||
<td>
|
||||
<input max={date('Y-m-d')} name="birthday" value={$user->getBirthday()->format('%Y-%m-%d')} type="date"/>
|
||||
<input max={date('Y-m-d')} name="birthday" value={is_null($user->getBirthday()) ? NULL : $user->getBirthday()->format('%Y-%m-%d')} type="date" style="margin-bottom: 7px;" />
|
||||
<select name="birthday_privacy">
|
||||
<option value="0" {if $user->getBirthdayPrivacy() == 0}selected{/if}>{_show_my_birthday}</option>
|
||||
<option value="1" {if $user->getBirthdayPrivacy() == 1}selected{/if}>{_show_only_month_and_day}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -372,13 +372,12 @@
|
|||
<td class="label"><span class="nobold">{_"politViews"}:</span></td>
|
||||
<td class="data">{var $pviews = $user->getPoliticalViews()}{_"politViews_$pviews"}</td>
|
||||
</tr>
|
||||
{if $user->getBirthday()->timestamp() > 0}
|
||||
<tr>
|
||||
<td class="label"><span class="nobold">{_"birth_date"}:</span></td>
|
||||
<td class="data">{$user->getBirthday()->format('%e %B %Y')},
|
||||
<tr n:if="!is_null($user->getBirthday())">
|
||||
<td class="label"><span class="nobold">{_"birth_date"}:</span></td>
|
||||
<td n:if="$user->getBirthdayPrivacy() == 0" class="data">{$user->getBirthday()->format('%e %B %Y')},
|
||||
{tr("years", $user->getAge())}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<td n:if="$user->getBirthdayPrivacy() == 1" class="data">{$user->getBirthday()->format('%e %B')}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -569,6 +569,7 @@ input[type~="email"],
|
|||
input[type~="phone"],
|
||||
input[type="search"],
|
||||
input[type~="search"],
|
||||
input[type~="date"],
|
||||
select {
|
||||
border: 1px solid #C0CAD5;
|
||||
padding: 3px;
|
||||
|
|
3
install/sqls/00026-better-birthdays.sql
Normal file
3
install/sqls/00026-better-birthdays.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `profiles` ADD COLUMN `birthday_privacy` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0;
|
||||
UPDATE `profiles` SET `birthday_privacy` = 2 WHERE `birthday` = 0;
|
||||
UPDATE `profiles` SET `birthday` = NULL WHERE `birthday` = 0;
|
|
@ -90,6 +90,9 @@
|
|||
"years_one" = "1 year old";
|
||||
"years_other" = "$1 years old";
|
||||
|
||||
"show_my_birthday" = "Show my birthday";
|
||||
"show_only_month_and_day" = "Show only month and day";
|
||||
|
||||
"relationship" = "Relationship";
|
||||
|
||||
"relationship_0" = "Not selected";
|
||||
|
|
|
@ -91,6 +91,9 @@
|
|||
"years_many" = "$1 лет";
|
||||
"years_other" = "$1 лет";
|
||||
|
||||
"show_my_birthday" = "Показывать дату рождения";
|
||||
"show_only_month_and_day" = "Показывать только день и месяц";
|
||||
|
||||
"relationship" = "Семейное положение";
|
||||
|
||||
"relationship_0" = "Не выбрано";
|
||||
|
|
Loading…
Reference in a new issue