From c53cd000d890199ae0af7a845727f13537d01e69 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 18 Dec 2021 18:25:03 +0100 Subject: [PATCH] Refactored the account page functionality and structure --- .../{Account_settings.php => Account.php} | 31 +++--- .../views/components/backend_header.php | 2 +- .../{account_settings.php => account.php} | 46 ++------ assets/js/http/account_http_client.js | 34 ++++++ assets/js/pages/account.js | 101 ++++++++++++++++++ 5 files changed, 161 insertions(+), 53 deletions(-) rename application/controllers/{Account_settings.php => Account.php} (76%) rename application/views/pages/{account_settings.php => account.php} (80%) create mode 100644 assets/js/http/account_http_client.js create mode 100644 assets/js/pages/account.js diff --git a/application/controllers/Account_settings.php b/application/controllers/Account.php similarity index 76% rename from application/controllers/Account_settings.php rename to application/controllers/Account.php index c5477691..47fb9c15 100644 --- a/application/controllers/Account_settings.php +++ b/application/controllers/Account.php @@ -12,15 +12,15 @@ * ---------------------------------------------------------------------------- */ /** - * Account settings controller. + * Account controller. * - * Handles current user settings related operations. + * Handles current account related operations. * * @package Controllers */ -class Account_settings extends EA_Controller { +class Account extends EA_Controller { /** - * Current_user constructor. + * Account constructor. */ public function __construct() { @@ -45,27 +45,32 @@ class Account_settings extends EA_Controller { */ public function index() { - session(['dest_url' => site_url('account_settings')]); + session(['dest_url' => site_url('account')]); if (cannot('view', PRIV_USER_SETTINGS)) { - abort(403,'Forbidden'); + abort(403, 'Forbidden'); } $user_id = session('user_id'); $role_slug = session('role_slug'); + $account = $this->users_model->find($user_id); + + script_vars([ + 'account' => $account, + ]); + html_vars([ 'page_title' => lang('settings'), 'active_menu' => PRIV_SYSTEM_SETTINGS, 'user_display_name' => $this->accounts->get_user_display_name($user_id), 'timezones' => $this->timezones->to_array(), 'privileges' => $this->roles_model->get_permissions_by_slug($role_slug), - 'user_settings' => $this->users_model->find($user_id), ]); - $this->load->view('pages/account_settings', html_vars()); + $this->load->view('pages/account', html_vars()); } /** @@ -80,14 +85,14 @@ class Account_settings extends EA_Controller { throw new Exception('You do not have the required permissions for this task.'); } - $settings = json_decode(request('settings'), TRUE); + $account = request('account'); - $this->users_model->save($settings); + $this->users_model->save($account); session([ - 'user_email' => $settings['email'], - 'username' => $settings['settings']['username'], - 'timezone' => $settings['timezone'], + 'user_email' => $account['email'], + 'username' => $account['settings']['username'], + 'timezone' => $account['timezone'], ]); response(); diff --git a/application/views/components/backend_header.php b/application/views/components/backend_header.php index 58061336..1f6f2859 100755 --- a/application/views/components/backend_header.php +++ b/application/views/components/backend_header.php @@ -101,7 +101,7 @@ - + diff --git a/application/views/pages/account_settings.php b/application/views/pages/account.php similarity index 80% rename from application/views/pages/account_settings.php rename to application/views/pages/account.php index f848971b..612cad12 100644 --- a/application/views/pages/account_settings.php +++ b/application/views/pages/account.php @@ -1,12 +1,3 @@ - - @@ -18,8 +9,8 @@
- -