diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 8ce180acd..1c1216aed 100644 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -17,7 +17,7 @@ class QSO extends CI_Controller { $this->load->model('stations'); $this->load->model('logbook_model'); $this->load->model('user_model'); - $this->load->model('modes'); + $this->load->model('usermodes'); $this->load->model('bands'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); } @@ -40,7 +40,7 @@ class QSO extends CI_Controller { $data['query'] = $this->logbook_model->last_custom($this->session->userdata('qso_page_last_qso_count')); $data['dxcc'] = $this->logbook_model->fetchDxcc(); $data['iota'] = $this->logbook_model->fetchIota(); - $data['modes'] = $this->modes->active(); + $data['modes'] = $this->usermodes->active(); $data['bands'] = $this->bands->get_user_bands_for_qso_entry(); [$data['lat'], $data['lng']] = $this->qra->qra2latlong($this->stations->gridsquare_from_station($this->stations->find_active())); $data['user_default_band'] = $this->session->userdata('user_default_band'); diff --git a/application/controllers/Usermode.php b/application/controllers/Usermode.php index cf9cec385..45ec3ac99 100644 --- a/application/controllers/Usermode.php +++ b/application/controllers/Usermode.php @@ -17,8 +17,8 @@ class Usermode extends CI_Controller { public function index() { - $this->load->model('modes'); - $data['modes'] = $this->modes->all(); + $this->load->model('usermodes'); + $data['modes'] = $this->usermodes->all(); // Render Page $data['page_title'] = __("Modes"); $this->load->view('interface_assets/header', $data); @@ -27,7 +27,7 @@ class Usermode extends CI_Controller { } public function activate() { - $id = $this->input->post('id'); + $id = $this->input->post('id',true); $this->load->model('usermodes'); $this->usermodes->activate($id); header('Content-Type: application/json'); @@ -36,7 +36,7 @@ class Usermode extends CI_Controller { } public function deactivate() { - $id = $this->input->post('id'); + $id = $this->input->post('id',true); $this->load->model('usermodes'); $this->usermodes->deactivate($id); header('Content-Type: application/json'); diff --git a/application/models/Usermodes.php b/application/models/Usermodes.php index 4468b3e6e..90ea491f0 100644 --- a/application/models/Usermodes.php +++ b/application/models/Usermodes.php @@ -23,6 +23,29 @@ class Usermodes extends CI_Model { return $retmodes; } + function active() { + $options_object = $this->user_options_model->get_options('usermodes', array('option_name' => 'enabled_usermodes', 'option_key' => 'json_modes'))->result(); + $usermodes = json_decode($options_object[0]->option_value ?? '[]'); + $this->db->where('active', 1); // Show only those which are not globally deactivated + $this->db->order_by('mode', 'ASC'); + $this->db->order_by('submode', 'ASC'); + $modes=$this->db->get('adif_modes'); + $retmodes=[]; + foreach ($modes->result() as $row) { + if (count($usermodes)>0) { + if (in_array($row->mode.'/'.($row_submode ?? ''), $usermodes)) { + $row->active=1; + $retmodes[]=$row; + } else { + $row->active=0; + } + } else { + $retmodes[]=$row; + } + } + return $retmodes; + } + function mode($id) { // Clean ID $clean_id = $this->security->xss_clean($id); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 2e6a4c794..07d4956e2 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -144,7 +144,7 @@