fix: profile view
This commit is contained in:
parent
b12548656e
commit
15bf22ba80
2 changed files with 65 additions and 22 deletions
|
@ -1,8 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* user.php
|
|
||||||
*
|
|
||||||
* A wishthis user.
|
* A wishthis user.
|
||||||
*
|
*
|
||||||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||||
|
@ -107,9 +105,9 @@ class User
|
||||||
/**
|
/**
|
||||||
* A unix timestamp of the users birthdate.
|
* 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`).
|
* 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->password_reset_valid_until = \strtotime($fields['password_reset_valid_until']);
|
||||||
$this->last_login = \strtotime($fields['last_login']);
|
$this->last_login = \strtotime($fields['last_login']);
|
||||||
$this->power = $fields['power'];
|
$this->power = $fields['power'];
|
||||||
$this->birthdate = \strtotime($fields['birthdate'] ?? 0);
|
$this->birthdate = $fields['birthdate'] ?? '';
|
||||||
$this->language = $fields['language'];
|
$this->language = $fields['language'];
|
||||||
$this->currency = $fields['currency'];
|
$this->currency = $fields['currency'];
|
||||||
$this->name_first = $fields['name_first'] ?? '';
|
$this->name_first = $fields['name_first'] ?? '';
|
||||||
|
@ -477,4 +475,49 @@ class User
|
||||||
{
|
{
|
||||||
return $this->power;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
$loginRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ if (isset($_POST['user-id'], $_POST['section'])) {
|
||||||
*/
|
*/
|
||||||
if (isset($_POST['user-birthdate'])) {
|
if (isset($_POST['user-birthdate'])) {
|
||||||
if (empty($_POST['user-birthdate'])) {
|
if (empty($_POST['user-birthdate'])) {
|
||||||
$user->birthdate = null;
|
$user->setBirthdate('');
|
||||||
|
|
||||||
$set[] = '`birthdate` = NULL';
|
$set[] = '`birthdate` = NULL';
|
||||||
} else {
|
} 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 */
|
/** 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'])) {
|
if (empty($_POST['user-channel'])) {
|
||||||
$user->channel = null;
|
$user->setChannel('');
|
||||||
|
|
||||||
$set[] = '`channel` = NULL';
|
$set[] = '`channel` = NULL';
|
||||||
} else {
|
} else {
|
||||||
$user->channel = $_POST['user-channel'];
|
$user->setChannel($_POST['user-channel']);
|
||||||
|
|
||||||
$set[] = '`channel` = "' . $user->channel . '"';
|
$set[] = '`channel` = "' . $_POST['user-channel'] . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Advertisements */
|
/** Advertisements */
|
||||||
if (isset($_POST['enable-advertisements'])) {
|
if (isset($_POST['enable-advertisements'])) {
|
||||||
$user->advertisements = true;
|
$user->setAdvertisements(true);
|
||||||
|
|
||||||
$set[] = '`advertisements` = TRUE';
|
$set[] = '`advertisements` = TRUE';
|
||||||
} else {
|
} else {
|
||||||
$user->advertisements = false;
|
$user->setAdvertisements(false);
|
||||||
|
|
||||||
$set[] = '`advertisements` = FALSE';
|
$set[] = '`advertisements` = FALSE';
|
||||||
}
|
}
|
||||||
|
@ -225,19 +225,19 @@ $page->navigation();
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label><?= __('First name') ?></label>
|
<label><?= __('First name') ?></label>
|
||||||
|
|
||||||
<input type="text" name="user-name-first" value="<?= $user->name_first ?>" />
|
<input type="text" name="user-name-first" value="<?= $user->getFirstName() ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label><?= __('Last name') ?></label>
|
<label><?= __('Last name') ?></label>
|
||||||
|
|
||||||
<input type="text" name="user-name-last" value="<?= $user->name_last ?>" />
|
<input type="text" name="user-name-last" value="<?= $user->getLastName() ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label><?= __('Nickname') ?></label>
|
<label><?= __('Nickname') ?></label>
|
||||||
|
|
||||||
<input type="text" name="user-name-nick" value="<?= $user->name_nick ?>" />
|
<input type="text" name="user-name-nick" value="<?= $user->getNickName() ?>" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ $page->navigation();
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label><?= __('Email') ?></label>
|
<label><?= __('Email') ?></label>
|
||||||
|
|
||||||
<input type="email" name="user-email" value="<?= $user->email ?>" />
|
<input type="email" name="user-email" value="<?= $user->getEmail() ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field" data-content="<?= __('Used to suggest a wishlist called "Birthday", if it\'s coming up.') ?>">
|
<div class="field" data-content="<?= __('Used to suggest a wishlist called "Birthday", if it\'s coming up.') ?>">
|
||||||
|
@ -260,7 +260,7 @@ $page->navigation();
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="user-birthdate"
|
name="user-birthdate"
|
||||||
placeholder="<?= __('Pick a date') ?>"
|
placeholder="<?= __('Pick a date') ?>"
|
||||||
value="<?= $user->birthdate ?>"
|
value="<?= $user->getBirthdate() ?>"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -462,7 +462,7 @@ $page->navigation();
|
||||||
<option value=""><?= __('Select channel') ?></option>
|
<option value=""><?= __('Select channel') ?></option>
|
||||||
|
|
||||||
<?php foreach (CHANNELS as $channel) { ?>
|
<?php foreach (CHANNELS as $channel) { ?>
|
||||||
<?php if ($channel['branch'] === $user->channel) { ?>
|
<?php if ($channel['branch'] === $user->getChannel()) { ?>
|
||||||
<option value="<?= $channel['branch'] ?>" selected><?= $channel['label'] ?></option>
|
<option value="<?= $channel['branch'] ?>" selected><?= $channel['label'] ?></option>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<option value="<?= $channel['branch'] ?>"><?= $channel['label'] ?></option>
|
<option value="<?= $channel['branch'] ?>"><?= $channel['label'] ?></option>
|
||||||
|
@ -519,7 +519,7 @@ $page->navigation();
|
||||||
<label><?= __('Advertisements') ?></label>
|
<label><?= __('Advertisements') ?></label>
|
||||||
|
|
||||||
<div class="ui toggle checkbox advertisements">
|
<div class="ui toggle checkbox advertisements">
|
||||||
<?php if (true === $user->advertisements) { ?>
|
<?php if (true === $user->getAdvertisements()) { ?>
|
||||||
<input type="checkbox" name="enable-advertisements" checked="checked" />
|
<input type="checkbox" name="enable-advertisements" checked="checked" />
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<input type="checkbox" name="enable-advertisements" />
|
<input type="checkbox" name="enable-advertisements" />
|
||||||
|
|
Loading…
Reference in a new issue