diff --git a/application/controllers/User.php b/application/controllers/User.php index 1f5f62509..e04b4469e 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -177,6 +177,10 @@ class User extends CI_Controller { $data['timezones'] = $this->user_model->timezones(); $data['user_language'] = 'english'; + // Values for the "dashboard last QSO count" selectbox + $data['dashboard_last_qso_count_limit'] = \User_Model::DASHBOARD_QSOS_COUNT_LIMIT; + $data['user_dashboard_last_qso_count'] = \User_Model::DASHBOARD_DEFAULT_QSOS_COUNT; + if ($this->form_validation->run() == FALSE) { $data['page_title'] = __("Add User"); $data['measurement_base'] = $this->config->item('measurement_base'); @@ -371,6 +375,9 @@ class User extends CI_Controller { // Get timezones $data['timezones'] = $this->user_model->timezones(); + // Max value to be present in the "dashboard last QSO count" selectbox + $data['dashboard_last_qso_count_limit'] = \User_Model::DASHBOARD_QSOS_COUNT_LIMIT; + $data['page_title'] = __("Edit User"); if ($this->form_validation->run() == FALSE) @@ -751,6 +758,23 @@ class User extends CI_Controller { $data['user_locations_quickswitch'] = ($this->user_options_model->get_options('header_menu', array('option_name'=>'locations_quickswitch'), $this->uri->segment(3))->row()->option_value ?? 'false'); $data['user_utc_headermenu'] = ($this->user_options_model->get_options('header_menu', array('option_name'=>'utc_headermenu'), $this->uri->segment(3))->row()->option_value ?? 'false'); + if($this->input->post('user_dashboard_last_qso_count', true)) { + $data['user_dashboard_last_qso_count'] = $this->input->post('user_dashboard_last_qso_count', true); + } else { + // Determine last (recent) QSO count to preselect into the selectbox + $last_qso_count_opt = $this->user_options_model->get_options( + 'dashboard', + array('option_name' => 'last_qso_count', 'option_key' => 'count'), + $this->uri->segment(3) + )->result(); + + if (count($last_qso_count_opt) > 0) { + $data['user_dashboard_last_qso_count'] = $last_qso_count_opt[0]->option_value; + } else { + $data['user_dashboard_last_qso_count'] = \User_Model::DASHBOARD_DEFAULT_QSOS_COUNT; + } + } + $this->load->view('interface_assets/header', $data); $this->load->view('user/edit', $data); $this->load->view('interface_assets/footer', $footerData); @@ -846,6 +870,7 @@ class User extends CI_Controller { $data['user_winkey'] = $this->input->post('user_winkey'); $data['user_hamsat_key'] = $this->input->post('user_hamsat_key'); $data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only'); + $data['user_dashboard_last_qso_count'] = $this->input->post('user_dashboard_last_qso_count', true); $this->load->view('user/edit'); $this->load->view('interface_assets/footer'); } diff --git a/application/models/User_model.php b/application/models/User_model.php index 23aa6df9b..d69366872 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -13,6 +13,9 @@ class User_Model extends CI_Model { + const DASHBOARD_DEFAULT_QSOS_COUNT = 20; // number of last QSOs used, if user has no value in settings yet + const DASHBOARD_QSOS_COUNT_LIMIT = 50; // hard limit for max number of QSOs shown on dashboard + // FUNCTION: object get($username) // Retrieve a user function get($username) { @@ -325,6 +328,10 @@ class User_Model extends CI_Model { 'winkey' => xss_clean($fields['user_winkey']), ); + // Hard limit safety check for last (recent) QSO count setting + $dashboard_last_qso_count = xss_clean($fields['user_dashboard_last_qso_count']); + $dashboard_last_qso_count = $dashboard_last_qso_count > self::DASHBOARD_QSOS_COUNT_LIMIT ? self::DASHBOARD_QSOS_COUNT_LIMIT : $dashboard_last_qso_count; + $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'hamsat','hamsat_key','api','".xss_clean($fields['user_hamsat_key'])."');"); $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'hamsat','hamsat_key','workable','".xss_clean($fields['user_hamsat_workable_only'])."');"); $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'qso_tab','iota','show',".(xss_clean($fields['user_iota_to_qso_tab'] ?? 'off') == "on" ? 1 : 0).");"); @@ -333,6 +340,7 @@ class User_Model extends CI_Model { $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'qso_tab','pota','show',".(xss_clean($fields['user_pota_to_qso_tab'] ?? 'off') == "on" ? 1 : 0).");"); $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'qso_tab','sig','show',".(xss_clean($fields['user_sig_to_qso_tab'] ?? 'off') == "on" ? 1 : 0).");"); $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'qso_tab','dok','show',".(xss_clean($fields['user_dok_to_qso_tab'] ?? 'off') == "on" ? 1 : 0).");"); + $this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'dashboard','last_qso_count','count','".$dashboard_last_qso_count."');"); // Check to see if the user is allowed to change user levels if($this->session->userdata('user_type') == 99) {