From 5ff5e128901d4aa4f924595a890e1fd7073a8162 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Fri, 22 Aug 2025 14:52:07 +0100 Subject: [PATCH] Add public radio status option to logbooks Introduces a new 'public_radio_status' field to station logbooks, allowing users to enable or disable the display of radio status on public logbook pages. Updates migration, controllers, model, views, and language files to support this feature and provide UI controls for toggling the option. --- application/config/migration.php | 2 +- application/controllers/Logbooks.php | 14 ++++++-- application/controllers/Visitor.php | 4 +++ .../chinese_simplified/station_lang.php | 2 ++ application/language/czech/station_lang.php | 2 ++ application/language/dutch/station_lang.php | 2 ++ application/language/english/station_lang.php | 2 ++ application/language/finnish/station_lang.php | 2 ++ application/language/french/station_lang.php | 2 ++ application/language/german/station_lang.php | 2 ++ .../language/portuguese/station_lang.php | 9 +++++ application/language/russian/station_lang.php | 2 ++ application/language/spanish/station_lang.php | 2 ++ application/language/swedish/station_lang.php | 2 ++ .../207_add_radio_panel_option_to_logbook.php | 29 +++++++++++++++ application/models/Logbooks_model.php | 10 ++++++ application/views/logbooks/edit.php | 35 ++++++++++++++++--- application/views/visitor/index.php | 4 ++- 18 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 application/migrations/207_add_radio_panel_option_to_logbook.php diff --git a/application/config/migration.php b/application/config/migration.php index 292abe53..52637be5 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 206; +$config['migration_version'] = 207; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php index 61938f5c..d99baa8b 100644 --- a/application/controllers/Logbooks.php +++ b/application/controllers/Logbooks.php @@ -131,8 +131,18 @@ class Logbooks extends CI_Controller { public function save_publicsearch() { $this->load->model('logbooks_model'); - $returndata = $this->logbooks_model->save_public_search($this->input->post('public_search'), $this->input->post('logbook_id')); - echo "
Public Search Settings Saved
"; + // Handle checkbox - if not checked, it won't be sent, so default to 0 + $public_search = $this->input->post('public_search') ? 1 : 0; + $returndata = $this->logbooks_model->save_public_search($public_search, $this->input->post('logbook_id')); + echo "
Public Search Settings Saved
"; + } + + public function save_publicradiostatus() { + $this->load->model('logbooks_model'); + // Handle checkbox - if not checked, it won't be sent, so default to 0 + $public_radio_status = $this->input->post('public_radio_status') ? 1 : 0; + $returndata = $this->logbooks_model->save_public_radio_status($public_radio_status, $this->input->post('logbook_id')); + echo "
Public Radio Status Settings Saved
"; } public function save_publicslug() { diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index 68ce5ed7..628adf79 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -67,6 +67,10 @@ class Visitor extends CI_Controller { { // Get associated station locations for mysql queries $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id); + + // Get logbook details to check public settings + $logbook_details = $this->logbooks_model->logbook($logbook_id); + $data['logbook_settings'] = $logbook_details->row(); if (!$logbooks_locations_array) { show_404('Empty Logbook'); diff --git a/application/language/chinese_simplified/station_lang.php b/application/language/chinese_simplified/station_lang.php index c51e2e28..54a41470 100644 --- a/application/language/chinese_simplified/station_lang.php +++ b/application/language/chinese_simplified/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "输入公共日志选项"; $lang['station_logbooks_public_slug_visit'] = "访问公开日志页面"; $lang['station_logbooks_public_search_hint'] = "启用公共搜索功能可在通过公共 slug 访问的公共日志页面上提供搜索输入框。 搜索仅涵盖此日志。"; $lang['station_logbooks_public_search_enabled'] = "启用公共搜索"; +$lang['station_logbooks_public_radio_status_hint'] = "启用公共电台状态将在通过公共 slug 访问的公共日志页面上显示当前电台状态信息。"; +$lang['station_logbooks_public_radio_status_enabled'] = "启用公共电台状态"; $lang['station_logbooks_select_avail_loc'] = "选择可用的台站位置"; $lang['station_logbooks_link_loc'] = "链接的台站位置"; $lang['station_logbooks_linked_loc'] = "已链接的台站位置"; diff --git a/application/language/czech/station_lang.php b/application/language/czech/station_lang.php index 01acd54b..0f0bbd8b 100644 --- a/application/language/czech/station_lang.php +++ b/application/language/czech/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "Type in Public Slug choice"; $lang['station_logbooks_public_slug_visit'] = "Visit Public Page"; $lang['station_logbooks_public_search_hint'] = "Enabling public search function offers a search input box on the public logbook page accessed via public slug. Search only covers this logbook."; $lang['station_logbooks_public_search_enabled'] = "Public search enabled"; +$lang['station_logbooks_public_radio_status_hint'] = "Enabling public radio status will display current radio status information on the public logbook page accessed via public slug."; +$lang['station_logbooks_public_radio_status_enabled'] = "Public radio status enabled"; $lang['station_logbooks_select_avail_loc'] = "Select Available Station Locations"; $lang['station_logbooks_link_loc'] = "Link Location"; $lang['station_logbooks_linked_loc'] = "Linked Locations"; diff --git a/application/language/dutch/station_lang.php b/application/language/dutch/station_lang.php index 01acd54b..0f0bbd8b 100644 --- a/application/language/dutch/station_lang.php +++ b/application/language/dutch/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "Type in Public Slug choice"; $lang['station_logbooks_public_slug_visit'] = "Visit Public Page"; $lang['station_logbooks_public_search_hint'] = "Enabling public search function offers a search input box on the public logbook page accessed via public slug. Search only covers this logbook."; $lang['station_logbooks_public_search_enabled'] = "Public search enabled"; +$lang['station_logbooks_public_radio_status_hint'] = "Enabling public radio status will display current radio status information on the public logbook page accessed via public slug."; +$lang['station_logbooks_public_radio_status_enabled'] = "Public radio status enabled"; $lang['station_logbooks_select_avail_loc'] = "Select Available Station Locations"; $lang['station_logbooks_link_loc'] = "Link Location"; $lang['station_logbooks_linked_loc'] = "Linked Locations"; diff --git a/application/language/english/station_lang.php b/application/language/english/station_lang.php index 1191b82d..2b193795 100644 --- a/application/language/english/station_lang.php +++ b/application/language/english/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "Type in Public Slug choice"; $lang['station_logbooks_public_slug_visit'] = "Visit Public Page"; $lang['station_logbooks_public_search_hint'] = "Enabling public search function offers a search input box on the public logbook page accessed via public slug. Search only covers this logbook."; $lang['station_logbooks_public_search_enabled'] = "Public search enabled"; +$lang['station_logbooks_public_radio_status_hint'] = "Enabling public radio status will display current radio status information on the public logbook page accessed via public slug."; +$lang['station_logbooks_public_radio_status_enabled'] = "Public radio status enabled"; $lang['station_logbooks_select_avail_loc'] = "Select Available Station Locations"; $lang['station_logbooks_link_loc'] = "Link Location"; $lang['station_logbooks_linked_loc'] = "Linked Locations"; diff --git a/application/language/finnish/station_lang.php b/application/language/finnish/station_lang.php index 01acd54b..0f0bbd8b 100644 --- a/application/language/finnish/station_lang.php +++ b/application/language/finnish/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "Type in Public Slug choice"; $lang['station_logbooks_public_slug_visit'] = "Visit Public Page"; $lang['station_logbooks_public_search_hint'] = "Enabling public search function offers a search input box on the public logbook page accessed via public slug. Search only covers this logbook."; $lang['station_logbooks_public_search_enabled'] = "Public search enabled"; +$lang['station_logbooks_public_radio_status_hint'] = "Enabling public radio status will display current radio status information on the public logbook page accessed via public slug."; +$lang['station_logbooks_public_radio_status_enabled'] = "Public radio status enabled"; $lang['station_logbooks_select_avail_loc'] = "Select Available Station Locations"; $lang['station_logbooks_link_loc'] = "Link Location"; $lang['station_logbooks_linked_loc'] = "Linked Locations"; diff --git a/application/language/french/station_lang.php b/application/language/french/station_lang.php index 6fe0fbe6..5e242020 100644 --- a/application/language/french/station_lang.php +++ b/application/language/french/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "Type in Public Slug choice"; $lang['station_logbooks_public_slug_visit'] = "Visit Public Page"; $lang['station_logbooks_public_search_hint'] = "Enabling public search function offers a search input box on the public logbook page accessed via public slug. Search only covers this logbook."; $lang['station_logbooks_public_search_enabled'] = "Public search enabled"; +$lang['station_logbooks_public_radio_status_hint'] = "Enabling public radio status will display current radio status information on the public logbook page accessed via public slug."; +$lang['station_logbooks_public_radio_status_enabled'] = "Public radio status enabled"; $lang['station_logbooks_select_avail_loc'] = "Select Available Station Locations"; $lang['station_logbooks_link_loc'] = "Link Location"; $lang['station_logbooks_linked_loc'] = "Linked Locations"; diff --git a/application/language/german/station_lang.php b/application/language/german/station_lang.php index 86846e85..024b8ce8 100644 --- a/application/language/german/station_lang.php +++ b/application/language/german/station_lang.php @@ -32,6 +32,8 @@ $lang['station_logbooks_public_slug_input'] = "Gib ein, wie der öffentliche Lin $lang['station_logbooks_public_slug_visit'] = "Besuche die öffentl. Seite"; $lang['station_logbooks_public_search_hint'] = "Einschalten der Suchfunktion gibt Besuchern deiner öffentlichen Logbuch Seite die Möglichkeit über ein Suchfeld Einträge zu suchen. Die Suche deckt dabei nur dieses Logbuch ab."; $lang['station_logbooks_public_search_enabled'] = "Öffentliche Suche eingeschaltet"; +$lang['station_logbooks_public_radio_status_hint'] = "Einschalten des Radio Status zeigt Besuchern der öffentlichen Logbuch Seite aktuelle Radio Status Informationen an."; +$lang['station_logbooks_public_radio_status_enabled'] = "Öffentlicher Radio Status eingeschaltet"; $lang['station_logbooks_select_avail_loc'] = "Wähle verfügbare Stationsstandorte"; $lang['station_logbooks_link_loc'] = "Verknüpfe Standort"; $lang['station_logbooks_linked_loc'] = "Verknüpfte Standorte"; diff --git a/application/language/portuguese/station_lang.php b/application/language/portuguese/station_lang.php index 7459544c..a744abe8 100644 --- a/application/language/portuguese/station_lang.php +++ b/application/language/portuguese/station_lang.php @@ -1,6 +1,13 @@ db->field_exists('public_radio_status', 'station_logbooks')) { + $fields = array( + 'public_radio_status integer DEFAULT 0 AFTER public_search', + ); + + $this->dbforge->add_column('station_logbooks', $fields); + } + } + + public function down() + { + if ($this->db->field_exists('public_radio_status', 'station_logbooks')) { + $this->dbforge->drop_column('station_logbooks', 'public_radio_status'); + } + } +} diff --git a/application/models/Logbooks_model.php b/application/models/Logbooks_model.php index 8b4ce1c3..48ca149f 100644 --- a/application/models/Logbooks_model.php +++ b/application/models/Logbooks_model.php @@ -220,6 +220,16 @@ class Logbooks_model extends CI_Model { $this->db->update('station_logbooks', $data); } + function save_public_radio_status($public_radio_status, $logbook_id) { + $data = array( + 'public_radio_status' => xss_clean($public_radio_status), + ); + + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('logbook_id', xss_clean($logbook_id)); + $this->db->update('station_logbooks', $data); + } + function save_public_slug($public_slug, $logbook_id) { $data = array( 'public_slug' => xss_clean($public_slug), diff --git a/application/views/logbooks/edit.php b/application/views/logbooks/edit.php index bb4ba43c..46f23f3e 100644 --- a/application/views/logbooks/edit.php +++ b/application/views/logbooks/edit.php @@ -73,15 +73,40 @@

- - +
+ public_search == 1) { echo " checked"; } ?> + hx-post="" + hx-target="#publicSearchForm" + hx-trigger="change" + hx-vals='{"logbook_id": "logbook_id; ?>"}'> + +

+ +
+ +

+
+ public_radio_status) && $station_logbook_details->public_radio_status == 1) { echo " checked"; } ?> + hx-post="" + hx-target="#publicRadioStatusForm" + hx-trigger="change" + hx-vals='{"logbook_id": "logbook_id; ?>"}'> + +
+
+

+

+
diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index 901a5ffb..b3676610 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -129,7 +129,9 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) {
-
+ public_radio_status) && $logbook_settings->public_radio_status == 1) { ?> +
+