Fix not being able to save cleared channel

This commit is contained in:
Jay Trees 2022-04-08 16:21:45 +02:00
parent 20b4fc24c3
commit 909eee9444

View file

@ -38,11 +38,6 @@ if (isset($_POST['user-id'], $_POST['section'])) {
'key' => 'user-locale', 'key' => 'user-locale',
'label' => __('Language'), 'label' => __('Language'),
), ),
array(
'column' => 'channel',
'key' => 'user-channel',
'label' => __('Channel'),
),
); );
$loginRequired = false; $loginRequired = false;
@ -66,6 +61,9 @@ if (isset($_POST['user-id'], $_POST['section'])) {
$loginRequired = true; $loginRequired = true;
} }
/**
* Personal
*/
if (isset($_POST['user-birthdate'])) { if (isset($_POST['user-birthdate'])) {
if (empty($_POST['user-birthdate'])) { if (empty($_POST['user-birthdate'])) {
$user->birthdate = null; $user->birthdate = null;
@ -78,6 +76,9 @@ if (isset($_POST['user-id'], $_POST['section'])) {
} }
} }
/**
* Password
*/
if ( if (
!empty($_POST['user-password']) !empty($_POST['user-password'])
&& !empty($_POST['user-password-repeat']) && !empty($_POST['user-password-repeat'])
@ -88,6 +89,21 @@ if (isset($_POST['user-id'], $_POST['section'])) {
$loginRequired = true; $loginRequired = true;
} }
/**
* Preferences
*/
if (isset($_POST['user-channel']) && $_POST['user-channel'] !== $user->channel) {
if (empty($_POST['user-channel'])) {
$user->channel = null;
$set[] = '`channel` = NULL';
} else {
$user->channel = $_POST['user-channel'];
$set[] = '`channel` = "' . $user->channel . '"';
}
}
if ($set) { if ($set) {
$database $database
->query('UPDATE `users` ->query('UPDATE `users`