From 22f7d0b78ac6554ced0f8a9b437a4b1af94154cb Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sun, 15 Feb 2026 18:47:58 +0100 Subject: [PATCH] allow clubstation operators to set websocket as default radio --- application/controllers/Radio.php | 77 ++++++++++++++++++++++++------- application/views/radio/index.php | 10 ++-- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/application/controllers/Radio.php b/application/controllers/Radio.php index 89f3c7c91..95b99bdc1 100644 --- a/application/controllers/Radio.php +++ b/application/controllers/Radio.php @@ -36,6 +36,9 @@ class Radio extends CI_Controller { $this->load->model('cat'); $query = $this->cat->status(); + // Get the default radio + $default_user_radio = $this->user_options_model->get_options('cat', array('option_name' => $this->_get_optionname()), $this->_get_correct_uid())->row()->option_value ?? NULL; + if ($query->num_rows() > 0) { echo ""; echo "" . __("Radio") . ""; @@ -50,6 +53,23 @@ class Radio extends CI_Controller { echo "" . __("Settings") . ""; echo ""; echo ""; + + // WebSocket as first row + echo ""; + echo "" . __("WebSocket") . ""; + echo "-"; // Frequency + echo "-"; // Mode + echo "-"; // Timestamp + echo ''; // Last updated + if ($default_user_radio === 'ws') { + echo ''; + } else { + echo ''; + } + echo ''; // Settings (no edit for WebSocket) + echo ''; // Delete (no delete for WebSocket) + echo ""; + foreach ($query->result() as $row) { echo ""; echo "" . $row->radio . ""; @@ -100,17 +120,10 @@ class Radio extends CI_Controller { echo ''; } - if ($this->session->userdata('clubstation') != 1) { - $defaul_user_radio = $this->user_options_model->get_options('cat', array('option_name' => 'default_radio'))->row()->option_value ?? NULL; - if (!$defaul_user_radio) { - echo '"; echo "id . "\" class=\"btn btn-sm btn-danger\"> " . __("Delete") . ""; @@ -118,8 +131,18 @@ class Radio extends CI_Controller { } echo ""; } else { + // No radios found - show WebSocket button + if ($default_user_radio === 'ws') { + $websocket_button = ''; + } else { + $websocket_button = ''; + } echo ""; - echo "
" . __("No CAT interfaced radios found.") . "
"; + echo "
"; + echo __("No CAT interfaced radios found."); + echo "

" . __("You can still set a default radio using the WebSocket option.") . "

"; + echo $websocket_button; + echo "
"; echo ""; } } @@ -302,11 +325,11 @@ class Radio extends CI_Controller { $this->cat->delete($clean_id); - if ($clean_id == $this->user_options_model->get_options('cat', array('option_name' => 'default_radio'))->row()->option_value ?? '') { + if ($clean_id == $this->user_options_model->get_options('cat', array('option_name' => $this->_get_optionname()), $this->_get_correct_uid())->row()->option_value ?? '') { $this->release_default_radio(); } - $this->session->set_flashdata('message', 'Radio Profile Deleted'); + $this->session->set_flashdata('message', __("Radio Profile Deleted")); session_write_close(); redirect('radio'); @@ -316,7 +339,7 @@ class Radio extends CI_Controller { // get the radio_id from POST $clean_radio_id = $this->input->post('radio_id', TRUE); - + // Check Auth $this->load->model('user_model'); if (!$this->user_model->authorize(3)) { @@ -328,7 +351,7 @@ class Radio extends CI_Controller { $this->release_default_radio(); // Set the user_option and session data - $this->user_options_model->set_option('cat', 'default_radio', array('radio_id' => $clean_radio_id)); + $this->user_options_model->set_option('cat', $this->_get_optionname(), array('radio_id' => $clean_radio_id), $this->_get_correct_uid()); $this->session->set_userdata('radio', $clean_radio_id); } @@ -341,7 +364,27 @@ class Radio extends CI_Controller { } // Unset the user_option and session data - $this->user_options_model->del_option('cat', 'default_radio'); + $this->user_options_model->del_option('cat', $this->_get_optionname(), NULL, $this->_get_correct_uid()); $this->session->unset_userdata('radio'); } + + private function _get_correct_uid() { + if ($this->_is_clubstation()) { + return $this->session->userdata('source_uid'); + } else { + return $this->session->userdata('user_id'); + } + } + + private function _is_clubstation() { + return $this->session->userdata('clubstation') == 1; + } + + private function _get_optionname() { + if ($this->_is_clubstation()) { + return 'default_clubradio_' . $this->session->userdata('user_id'); + } else { + return 'default_radio'; + } + } } diff --git a/application/views/radio/index.php b/application/views/radio/index.php index e4f1533b3..8b6ad2417 100644 --- a/application/views/radio/index.php +++ b/application/views/radio/index.php @@ -20,15 +20,19 @@
-

-

+

+ session->userdata('clubstation') == 1) { ?> +

+ +

+

' . __("radio functions") . ''); ?>

-

+