From 909eee9444db76cda804ad753f4cba0f5b8bdc57 Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Fri, 8 Apr 2022 16:21:45 +0200 Subject: [PATCH] Fix not being able to save cleared channel --- src/pages/profile.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/pages/profile.php b/src/pages/profile.php index ee35937f..fa9be94b 100644 --- a/src/pages/profile.php +++ b/src/pages/profile.php @@ -38,11 +38,6 @@ if (isset($_POST['user-id'], $_POST['section'])) { 'key' => 'user-locale', 'label' => __('Language'), ), - array( - 'column' => 'channel', - 'key' => 'user-channel', - 'label' => __('Channel'), - ), ); $loginRequired = false; @@ -66,6 +61,9 @@ if (isset($_POST['user-id'], $_POST['section'])) { $loginRequired = true; } + /** + * Personal + */ if (isset($_POST['user-birthdate'])) { if (empty($_POST['user-birthdate'])) { $user->birthdate = null; @@ -78,6 +76,9 @@ if (isset($_POST['user-id'], $_POST['section'])) { } } + /** + * Password + */ if ( !empty($_POST['user-password']) && !empty($_POST['user-password-repeat']) @@ -88,6 +89,21 @@ if (isset($_POST['user-id'], $_POST['section'])) { $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) { $database ->query('UPDATE `users`