From 15bf22ba80cb7ac8c759c87bd069c7f97a98e3fd Mon Sep 17 00:00:00 2001 From: grandeljay Date: Wed, 6 Sep 2023 11:09:13 +0200 Subject: [PATCH] fix: profile view --- src/classes/wishthis/User.php | 53 +++++++++++++++++++++++++++++++---- src/pages/profile.php | 34 +++++++++++----------- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/src/classes/wishthis/User.php b/src/classes/wishthis/User.php index c0873e6a..95aa27df 100644 --- a/src/classes/wishthis/User.php +++ b/src/classes/wishthis/User.php @@ -1,8 +1,6 @@ @@ -107,9 +105,9 @@ class User /** * A unix timestamp of the users birthdate. * - * @var int|null + * @var string */ - private ?int $birthdate; + private string $birthdate; /** * More accurately, this is the users locale (e. g. `en_GB`). @@ -176,7 +174,7 @@ class User $this->password_reset_valid_until = \strtotime($fields['password_reset_valid_until']); $this->last_login = \strtotime($fields['last_login']); $this->power = $fields['power']; - $this->birthdate = \strtotime($fields['birthdate'] ?? 0); + $this->birthdate = $fields['birthdate'] ?? ''; $this->language = $fields['language']; $this->currency = $fields['currency']; $this->name_first = $fields['name_first'] ?? ''; @@ -477,4 +475,49 @@ class User { return $this->power; } + + public function getFirstName(): string + { + return $this->name_first; + } + + public function getLastName(): string + { + return $this->name_last; + } + + public function getNickName(): string + { + return $this->name_nick; + } + + public function getBirthdate(): string + { + return $this->birthdate; + } + + public function setBirthdate(string $birthdate): void + { + $this->birthdate = $birthdate; + } + + public function getChannel(): string + { + return $this->channel; + } + + public function setChannel(string $channel): void + { + $this->channel = $channel; + } + + public function getAdvertisements(): bool + { + return $this->advertisements; + } + + public function setAdvertisements(bool $advertisements): void + { + $this->advertisements = $advertisements; + } } diff --git a/src/pages/profile.php b/src/pages/profile.php index 401c920d..0561495d 100644 --- a/src/pages/profile.php +++ b/src/pages/profile.php @@ -53,7 +53,7 @@ if (isset($_POST['user-id'], $_POST['section'])) { } } - if (!empty($_POST['user-email']) && $_POST['user-email'] !== $user->email) { + if (!empty($_POST['user-email']) && $_POST['user-email'] !== $user->getEmail()) { $loginRequired = true; } @@ -62,13 +62,13 @@ if (isset($_POST['user-id'], $_POST['section'])) { */ if (isset($_POST['user-birthdate'])) { if (empty($_POST['user-birthdate'])) { - $user->birthdate = null; + $user->setBirthdate(''); $set[] = '`birthdate` = NULL'; } else { - $user->birthdate = date('Y-m-d', strtotime($_POST['user-birthdate'])); + $user->setBirthdate($_POST['user-birthdate']); - $set[] = '`birthdate` = "' . $user->birthdate . '"'; + $set[] = '`birthdate` = "' . $_POST['user-birthdate'] . '"'; } } @@ -122,25 +122,25 @@ if (isset($_POST['user-id'], $_POST['section'])) { } /** Channel */ - if (isset($_POST['user-channel']) && $_POST['user-channel'] !== $user->channel) { + if (isset($_POST['user-channel']) && $_POST['user-channel'] !== $user->getChannel()) { if (empty($_POST['user-channel'])) { - $user->channel = null; + $user->setChannel(''); $set[] = '`channel` = NULL'; } else { - $user->channel = $_POST['user-channel']; + $user->setChannel($_POST['user-channel']); - $set[] = '`channel` = "' . $user->channel . '"'; + $set[] = '`channel` = "' . $_POST['user-channel'] . '"'; } } /** Advertisements */ if (isset($_POST['enable-advertisements'])) { - $user->advertisements = true; + $user->setAdvertisements(true); $set[] = '`advertisements` = TRUE'; } else { - $user->advertisements = false; + $user->setAdvertisements(false); $set[] = '`advertisements` = FALSE'; } @@ -225,19 +225,19 @@ $page->navigation();
- +
- +
- +
@@ -245,7 +245,7 @@ $page->navigation();
- +
"> @@ -260,7 +260,7 @@ $page->navigation();
@@ -462,7 +462,7 @@ $page->navigation(); - channel) { ?> + getChannel()) { ?> @@ -519,7 +519,7 @@ $page->navigation();
- advertisements) { ?> + getAdvertisements()) { ?>