diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php
index 03948970..d5726f25 100644
--- a/Web/Models/Entities/User.php
+++ b/Web/Models/Entities/User.php
@@ -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
diff --git a/Web/Presenters/AuthPresenter.php b/Web/Presenters/AuthPresenter.php
index 8d15d3e2..ad0db0c7 100644
--- a/Web/Presenters/AuthPresenter.php
+++ b/Web/Presenters/AuthPresenter.php
@@ -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"));
diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php
index e27caf68..cc39a0b5 100644
--- a/Web/Presenters/UserPresenter.php
+++ b/Web/Presenters/UserPresenter.php
@@ -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"));
diff --git a/Web/Presenters/templates/User/Edit.xml b/Web/Presenters/templates/User/Edit.xml
index 2ebc21c5..89057064 100644
--- a/Web/Presenters/templates/User/Edit.xml
+++ b/Web/Presenters/templates/User/Edit.xml
@@ -145,7 +145,11 @@
{_"birth_date"}:
- getBirthday()->format('%Y-%m-%d')} type="date"/>
+ getBirthday()) ? NULL : $user->getBirthday()->format('%Y-%m-%d')} type="date" style="margin-bottom: 7px;" />
+
|
diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml
index 22015765..c0d92e7a 100644
--- a/Web/Presenters/templates/User/View.xml
+++ b/Web/Presenters/templates/User/View.xml
@@ -372,13 +372,12 @@
{_"politViews"}: |
{var $pviews = $user->getPoliticalViews()}{_"politViews_$pviews"} |
- {if $user->getBirthday()->timestamp() > 0}
-
- {_"birth_date"}: |
- {$user->getBirthday()->format('%e %B %Y')},
+ |
+ {_"birth_date"}: |
+ {$user->getBirthday()->format('%e %B %Y')},
{tr("years", $user->getAge())} |
-
- {/if}
+ {$user->getBirthday()->format('%e %B')} |
+
diff --git a/Web/static/css/style.css b/Web/static/css/style.css
index 4e1ec2e6..52fec25f 100644
--- a/Web/static/css/style.css
+++ b/Web/static/css/style.css
@@ -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;
diff --git a/install/sqls/00026-better-birthdays.sql b/install/sqls/00026-better-birthdays.sql
new file mode 100644
index 00000000..7a6b2f05
--- /dev/null
+++ b/install/sqls/00026-better-birthdays.sql
@@ -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;
diff --git a/locales/en.strings b/locales/en.strings
index 745c47e7..ef6fdf43 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -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";
diff --git a/locales/ru.strings b/locales/ru.strings
index bb564eb0..4b9be95c 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -91,6 +91,9 @@
"years_many" = "$1 лет";
"years_other" = "$1 лет";
+"show_my_birthday" = "Показывать дату рождения";
+"show_only_month_and_day" = "Показывать только день и месяц";
+
"relationship" = "Семейное положение";
"relationship_0" = "Не выбрано";