From 44675e95d630923e2333d12ddd1c9ba3c526d2b9 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 28 Dec 2016 18:08:07 +0200 Subject: [PATCH] user_group_id remove bug fix --- src/app/frontend/controllers/CustomerController.php | 3 ++- src/lib/models/customers.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/app/frontend/controllers/CustomerController.php b/src/app/frontend/controllers/CustomerController.php index 5aeafe4..67958bd 100644 --- a/src/app/frontend/controllers/CustomerController.php +++ b/src/app/frontend/controllers/CustomerController.php @@ -528,7 +528,8 @@ class CustomerController extends \controllers\ControllerBase if( $this->models->getCustomers()->editCustomer( $customer_edit ) ) { $this->flash->success( $this->languages->getTranslation()->_("successfully_changed_your_profile") ); - $this->session->set('users_group_id', $customer_edit['users_group_id']); + + if (!empty($customer_edit['users_group_id'])) $this->session->set('users_group_id', $customer_edit['users_group_id']); return $this->response->redirect($_SERVER['HTTP_REFERER']); } else diff --git a/src/lib/models/customers.php b/src/lib/models/customers.php index 269985d..4e99438 100644 --- a/src/lib/models/customers.php +++ b/src/lib/models/customers.php @@ -634,9 +634,9 @@ class customers extends \db } public function editCustomer( $customer_edit ) { - - return $this->exec( - ' + if (!empty($customer_edit['users_group_id'])) { + return $this->exec( + ' UPDATE public.customers SET @@ -654,19 +654,50 @@ class customers extends \db WHERE id=:id ', - [ - 'name' => $customer_edit['name'], - 'passwd' => $customer_edit['passwd'], - 'email' => $customer_edit['email'], - 'birth_date' => $customer_edit['birth_date'], - 'phone' => $customer_edit['phone'], - 'city' => $customer_edit['city'], - 'address' => !empty($customer_edit['address']) ? $customer_edit['address'] : '', - 'subscribed' => $customer_edit['subscribed'], - 'id' => $customer_edit['id'], - 'users_group_id'=> !empty($customer_edit['users_group_id']) ? $customer_edit['users_group_id'] : null - ] - ); + [ + 'name' => $customer_edit['name'], + 'passwd' => $customer_edit['passwd'], + 'email' => $customer_edit['email'], + 'birth_date' => $customer_edit['birth_date'], + 'phone' => $customer_edit['phone'], + 'city' => $customer_edit['city'], + 'address' => !empty($customer_edit['address']) ? $customer_edit['address'] : '', + 'subscribed' => $customer_edit['subscribed'], + 'id' => $customer_edit['id'], + 'users_group_id'=> !empty($customer_edit['users_group_id']) ? $customer_edit['users_group_id'] : null + ] + ); + } + else { + return $this->exec( + ' + UPDATE + public.customers + SET + name = :name, + passwd = :passwd, + email = :email, + birth_date = :birth_date, + phone = :phone, + city = :city, + address = :address, + subscribed = :subscribed + WHERE + id=:id + ', + [ + 'name' => $customer_edit['name'], + 'passwd' => $customer_edit['passwd'], + 'email' => $customer_edit['email'], + 'birth_date' => $customer_edit['birth_date'], + 'phone' => $customer_edit['phone'], + 'city' => $customer_edit['city'], + 'address' => !empty($customer_edit['address']) ? $customer_edit['address'] : '', + 'subscribed' => $customer_edit['subscribed'], + 'id' => $customer_edit['id'] + ] + ); + } } ///////////////////////////////////////////////////////////////////////////// -- libgit2 0.21.4