diff --git a/application/controllers/User.php b/application/controllers/User.php index aed72819e..fdd0bf990 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -302,12 +302,12 @@ class User extends CI_Controller { $this->input->post('qso_widget_display_qso_time'), $this->input->post('user_dashboard_banner') ?? 'Y', $this->input->post('user_dashboard_solar') ?? 'Y', - $this->input->post('clubstation') == '1' ? true : false, $this->input->post('global_oqrs_text') ?? '', $this->input->post('oqrs_grouped_search') ?? 'off', $this->input->post('oqrs_grouped_search_show_station_name') ?? 'off', $this->input->post('oqrs_auto_matching') ?? 'on', - $this->input->post('oqrs_direct_auto_matching') ?? 'on') + $this->input->post('oqrs_direct_auto_matching') ?? 'on', + $this->input->post('clubstation') == '1' ? true : false) ) { // Check for errors case EUSERNAMEEXISTS: @@ -913,32 +913,35 @@ class User extends CI_Controller { ); $this->input->set_cookie($cookie); } - if($this->session->userdata('user_id') == $this->input->post('id', true)) { - // [MAP Custom] ADD to user options // - $array_icon = array('station','qso','qsoconfirm'); + + $user_id = $this->input->post('id', true); + + // [MAP Custom] ADD to user options // + $array_icon = array('station','qso','qsoconfirm'); + foreach ($array_icon as $icon) { + $data_options['user_map_'.$icon.'_icon'] = xss_clean($this->input->post('user_map_'.$icon.'_icon', true)); + $data_options['user_map_'.$icon.'_color'] = xss_clean($this->input->post('user_map_'.$icon.'_color', true)); + } + if (!empty($data_options['user_map_qso_icon'])) { foreach ($array_icon as $icon) { - $data_options['user_map_'.$icon.'_icon'] = xss_clean($this->input->post('user_map_'.$icon.'_icon', true)); - $data_options['user_map_'.$icon.'_color'] = xss_clean($this->input->post('user_map_'.$icon.'_color', true)); + $json = json_encode(array('icon'=>$data_options['user_map_'.$icon.'_icon'], 'color'=>$data_options['user_map_'.$icon.'_color'])); + $this->user_options_model->set_option('map_custom','icon',array($icon=>$json), $user_id); } - if (!empty($data_options['user_map_qso_icon'])) { - foreach ($array_icon as $icon) { - $json = json_encode(array('icon'=>$data_options['user_map_'.$icon.'_icon'], 'color'=>$data_options['user_map_'.$icon.'_color'])); - $this->user_options_model->set_option('map_custom','icon',array($icon=>$json)); - } - $this->user_options_model->set_option('map_custom','gridsquare',array('show'=>xss_clean($this->input->post('user_map_gridsquare_show', true)))); - } else { - $this->user_options_model->del_option('map_custom','icon'); - $this->user_options_model->del_option('map_custom','gridsquare'); - } - $this->user_options_model->set_option('header_menu', 'locations_quickswitch', array('boolean'=>xss_clean($this->input->post('user_locations_quickswitch', true)))); - $this->user_options_model->set_option('header_menu', 'utc_headermenu', array('boolean'=>xss_clean($this->input->post('user_utc_headermenu', true)))); + $this->user_options_model->set_option('map_custom','gridsquare',array('show'=>xss_clean($this->input->post('user_map_gridsquare_show', true))), $user_id); + } else { + $this->user_options_model->del_option('map_custom','icon', null, $user_id); + $this->user_options_model->del_option('map_custom','gridsquare', null, $user_id); + } + $this->user_options_model->set_option('header_menu', 'locations_quickswitch', array('boolean'=>xss_clean($this->input->post('user_locations_quickswitch', true))), $user_id); + $this->user_options_model->set_option('header_menu', 'utc_headermenu', array('boolean'=>xss_clean($this->input->post('user_utc_headermenu', true))), $user_id); - $this->user_options_model->set_option('oqrs', 'global_oqrs_text', array('text'=>$this->input->post('global_oqrs_text', true))); - $this->user_options_model->set_option('oqrs', 'oqrs_grouped_search', array('boolean'=>$this->input->post('oqrs_grouped_search', true))); - $this->user_options_model->set_option('oqrs', 'oqrs_grouped_search_show_station_name', array('boolean'=>$this->input->post('oqrs_grouped_search_show_station_name', true))); - $this->user_options_model->set_option('oqrs', 'oqrs_auto_matching', array('boolean'=>$this->input->post('oqrs_auto_matching', true))); - $this->user_options_model->set_option('oqrs', 'oqrs_direct_auto_matching', array('boolean'=>$this->input->post('oqrs_direct_auto_matching', true))); + $this->user_options_model->set_option('oqrs', 'global_oqrs_text', array('text'=>$this->input->post('global_oqrs_text', true)), $user_id); + $this->user_options_model->set_option('oqrs', 'oqrs_grouped_search', array('boolean'=>$this->input->post('oqrs_grouped_search', true)), $user_id); + $this->user_options_model->set_option('oqrs', 'oqrs_grouped_search_show_station_name', array('boolean'=>$this->input->post('oqrs_grouped_search_show_station_name', true)), $user_id); + $this->user_options_model->set_option('oqrs', 'oqrs_auto_matching', array('boolean'=>$this->input->post('oqrs_auto_matching', true)), $user_id); + $this->user_options_model->set_option('oqrs', 'oqrs_direct_auto_matching', array('boolean'=>$this->input->post('oqrs_direct_auto_matching', true)), $user_id); + if($this->session->userdata('user_id') == $user_id) { $this->session->set_flashdata('success', sprintf(__("User %s edited"), $this->input->post('user_name', true))); redirect('user/edit/'.$this->uri->segment(3)); } else { diff --git a/application/models/User_model.php b/application/models/User_model.php index a189f1546..219609c27 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -224,7 +224,8 @@ class User_Model extends CI_Model { $user_wwff_to_qso_tab, $user_pota_to_qso_tab, $user_sig_to_qso_tab, $user_dok_to_qso_tab, $user_lotw_name, $user_lotw_password, $user_eqsl_name, $user_eqsl_password, $user_clublog_name, $user_clublog_password, $user_winkey, $on_air_widget_enabled, $on_air_widget_display_last_seen, $on_air_widget_show_only_most_recent_radio, - $qso_widget_display_qso_time, $dashboard_banner,$dashboard_solar, $clubstation = 0) { + $qso_widget_display_qso_time, $dashboard_banner, $dashboard_solar, $global_oqrs_text, $oqrs_grouped_search, + $oqrs_grouped_search_show_station_name, $oqrs_auto_matching, $oqrs_direct_auto_matching, $clubstation = 0) { // Check that the user isn't already used if(!$this->exists($username)) { $data = array( diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php index a8d3e174c..ba047a661 100644 --- a/application/models/User_options_model.php +++ b/application/models/User_options_model.php @@ -52,8 +52,11 @@ class User_options_model extends CI_Model { return $this->db->query($sql, $array_sql_value); } - public function del_option($option_type, $option_name, $option_array=null) { - $uid=$this->session->userdata('user_id'); + public function del_option($option_type, $option_name, $option_array = null, $uid = null) { + if (($uid ?? '') == '') { + $uid = $this->session->userdata('user_id'); + } + $sql_more = ""; $array_sql_value = array($uid, $option_type, $option_name); if (is_array($option_array)) { @@ -62,7 +65,7 @@ class User_options_model extends CI_Model { $array_sql_value[] = $value; } } - $sql='delete from user_options where user_id=? and option_type=? and option_name=?'.$sql_more; + $sql='delete from user_options where user_id = ? and option_type = ? and option_name = ?'.$sql_more; return $this->db->query($sql, $array_sql_value); }