From 6c07de7f2cd66b8b8a4a32d7ff57b8c8406403ec Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 14 Sep 2020 12:29:02 +0200 Subject: [PATCH] Changed it over to user profile. Fetches data from session instead. --- application/controllers/Logbook.php | 27 +++---------------- application/controllers/User.php | 8 ++++++ ...php => 049_add_users_measurement_base.php} | 6 ++--- application/models/Stations.php | 2 -- application/models/User_model.php | 4 ++- application/views/station_profile/create.php | 10 ------- application/views/station_profile/edit.php | 10 ------- application/views/user/add.php | 10 +++++++ application/views/user/edit.php | 10 +++++++ 9 files changed, 38 insertions(+), 49 deletions(-) rename application/migrations/{049_add_stationprofile_measurement_base.php => 049_add_users_measurement_base.php} (57%) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 4b383ba6..2598459f 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -99,7 +99,7 @@ class Logbook extends CI_Controller { $return['callsign_qth'] = $this->logbook_model->call_qth($callsign); $return['callsign_iota'] = $this->logbook_model->call_iota($callsign); $return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign); - $return['bearing'] = $this->bearing($return['callsign_qra'], $this->getMeasurementBase()); + $return['bearing'] = $this->bearing($return['callsign_qra'], $this->session->userdata('user_measurement_base')); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); if ($return['callsign_qra'] != "") { @@ -161,7 +161,7 @@ class Logbook extends CI_Controller { } $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode); } - $return['bearing'] = $this->bearing($return['callsign_qra'], $this->getMeasurementBase()); + $return['bearing'] = $this->bearing($return['callsign_qra'], $this->session->userdata('user_measurement_base')); echo json_encode($return, JSON_PRETTY_PRINT); @@ -367,7 +367,7 @@ class Logbook extends CI_Controller { $this->load->model('logbook_model'); $data['query'] = $this->logbook_model->get_qso($id); - $data['measurement_base'] = $this->getMeasurementBase(); + $data['measurement_base'] = $this->session->userdata('user_measurement_base'); $this->load->view('interface_assets/mini_header', $data); $this->load->view('view_log/qso'); @@ -591,7 +591,7 @@ class Logbook extends CI_Controller { $mylocator = $this->config->item('locator'); } - $bearing = $this->qra->bearing($mylocator, $locator, $this->getMeasurementBase()); + $bearing = $this->qra->bearing($mylocator, $locator, $this->session->userdata('user_measurement_base')); echo $bearing; } @@ -631,25 +631,6 @@ class Logbook extends CI_Controller { print json_encode($latlng); } - function getMeasurementBase() { - $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } - - $CI =& get_instance(); - $CI->load->model('Stations'); - $station_id = $CI->Stations->find_active(); - - $this->db->select('measurement_base'); - - $this->db->from('station_profile'); - - $this->db->where('station_id', $station_id); - - $result = $this->db->get(); - - return $result->row()->measurement_base; - } - function get_qsos($num, $offset) { $this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); $this->db->from($this->config->item('table_name')); diff --git a/application/controllers/User.php b/application/controllers/User.php index 0a9e37be..b6b7515b 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -52,6 +52,7 @@ class User extends CI_Controller { $data['user_callsign'] = $this->input->post('user_callsign'); $data['user_locator'] = $this->input->post('user_locator'); $data['user_timezone'] = $this->input->post('user_timezone'); + $data['user_measurement_base'] = $this->input->post('user_measurement_base'); $this->load->view('user/add', $data); } else { $this->load->view('user/add', $data); @@ -88,6 +89,7 @@ class User extends CI_Controller { $data['user_lastname'] = $this->input->post('user_lastname'); $data['user_callsign'] = $this->input->post('user_callsign'); $data['user_locator'] = $this->input->post('user_locator'); + $data['user_measurement_base'] = $this->input->post('user_measurement_base'); $this->load->view('user/add', $data); $this->load->view('interface_assets/footer'); } @@ -225,6 +227,12 @@ class User extends CI_Controller { } else { $data['user_eqsl_password'] = $q->user_eqsl_password; } + + if($this->input->post('user_measurement_base')) { + $data['user_measurement_base'] = $this->input->post('user_measurement_base', true); + } else { + $data['user_measurement_base'] = $q->user_measurement_base; + } $this->load->view('user/edit', $data); diff --git a/application/migrations/049_add_stationprofile_measurement_base.php b/application/migrations/049_add_users_measurement_base.php similarity index 57% rename from application/migrations/049_add_stationprofile_measurement_base.php rename to application/migrations/049_add_users_measurement_base.php index 974b35df..34c5a7ee 100644 --- a/application/migrations/049_add_stationprofile_measurement_base.php +++ b/application/migrations/049_add_users_measurement_base.php @@ -7,14 +7,14 @@ class Migration_add_stationprofile_measurement_base extends CI_Migration { public function up() { $fields = array( - 'measurement_base varchar(1) DEFAULT "K"', + 'user_measurement_base varchar(1) DEFAULT "K"', ); - $this->dbforge->add_column('station_profile', $fields); + $this->dbforge->add_column('users', $fields); } public function down() { - $this->dbforge->drop_column('station_profile', 'measurement_base'); + $this->dbforge->drop_column('users', 'user_measurement_base'); } } \ No newline at end of file diff --git a/application/models/Stations.php b/application/models/Stations.php index 8dd06e44..e5110a8e 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -47,7 +47,6 @@ class Stations extends CI_Model { 'state' => xss_clean($this->input->post('station_state', true)), 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), - 'measurement_base' => xss_clean($this->input->post('measurement_base', true)), ); $this->db->insert('station_profile', $data); @@ -69,7 +68,6 @@ class Stations extends CI_Model { 'state' => xss_clean($this->input->post('station_state', true)), 'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)), 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), - 'measurement_base' => xss_clean($this->input->post('measurement_base', true)), ); $this->db->where('station_id', xss_clean($this->input->post('station_id', true))); diff --git a/application/models/User_model.php b/application/models/User_model.php index ab99154f..c80ad00f 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -138,6 +138,7 @@ class User_Model extends CI_Model { 'user_lotw_name' => xss_clean($fields['user_lotw_name']), 'user_eqsl_name' => xss_clean($fields['user_eqsl_name']), 'user_clublog_name' => xss_clean($fields['user_clublog_name']), + 'user_measurement_base' => xss_clean($fields['user_measurement_base']), ); // Check to see if the user is allowed to change user levels @@ -241,7 +242,8 @@ class User_Model extends CI_Model { 'user_eqsl_qth_nickname' => $u->row()->user_eqsl_qth_nickname, 'user_hash' => $this->_hash($u->row()->user_id."-".$u->row()->user_type), 'radio' => isset($_COOKIE["radio"])?$_COOKIE["radio"]:"", - 'station_profile_id' => isset($_COOKIE["station_profile_id"])?$_COOKIE["station_profile_id"]:"" + 'station_profile_id' => isset($_COOKIE["station_profile_id"])?$_COOKIE["station_profile_id"]:"", + 'user_measurement_base' => $u->row()->user_measurement_base, ); $this->session->set_userdata($userdata); diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index 69781cac..e7d77451 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -165,16 +165,6 @@ Your QRZ.com Logbook API can be found in the settings page -
- - - Choose which unit distances will be shown in. -
- diff --git a/application/views/station_profile/edit.php b/application/views/station_profile/edit.php index 82c58a66..f6417181 100644 --- a/application/views/station_profile/edit.php +++ b/application/views/station_profile/edit.php @@ -179,16 +179,6 @@ Your QRZ.com Logbook API can be found in the settings page -
- - - Choose which unit distances will be shown in. -
- diff --git a/application/views/user/add.php b/application/views/user/add.php index d33f7184..6e83a4cd 100644 --- a/application/views/user/add.php +++ b/application/views/user/add.php @@ -82,6 +82,16 @@ ?> +
+ + + Choose which unit distances will be shown in. +
+ diff --git a/application/views/user/edit.php b/application/views/user/edit.php index bed04425..f2db4810 100644 --- a/application/views/user/edit.php +++ b/application/views/user/edit.php @@ -135,6 +135,16 @@ +
+ + + Choose which unit distances will be shown in. +
+