From dc94d47106464207a84271c8c721938639525c9d Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 24 May 2024 20:49:18 +0200 Subject: [PATCH 01/19] formatted code --- application/controllers/Activators.php | 59 ++++++---- application/models/Activators_model.php | 140 +++++++++++------------ application/views/activators/index.php | 146 ++++++++++++------------ 3 files changed, 177 insertions(+), 168 deletions(-) diff --git a/application/controllers/Activators.php b/application/controllers/Activators.php index 6c66d5420..73d01fe96 100644 --- a/application/controllers/Activators.php +++ b/application/controllers/Activators.php @@ -1,14 +1,18 @@ load->model('user_model'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + if (!$this->user_model->authorize(2)) { + $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); + redirect('dashboard'); + } } public function index() @@ -20,8 +24,7 @@ class Activators extends CI_Controller { if ($this->input->post('band') != NULL) { // Band is not set when page first loads. $band = $this->input->post('band'); - } - else { + } else { $band = 'All'; } @@ -38,38 +41,44 @@ class Activators extends CI_Controller { $this->load->view('interface_assets/footer'); } - public function details() { + public function details() + { $this->load->model('logbook_model'); $call = str_replace('"', "", $this->input->post("Callsign")); $band = str_replace('"', "", $this->input->post("Band")); $leogeo = str_replace('"', "", $this->input->post("LeoGeo")); $data['results'] = $this->logbook_model->activator_details($call, $band, $leogeo); - $data['filter'] = "Call ".$call; - switch($band) { - case 'All': $data['page_title'] = "Log View All Bands"; - $data['filter'] .= " and Band All"; - break; - case 'SAT': $data['page_title'] = "Log View SAT"; - $data['filter'] .= " and Band SAT"; - break; - default: $data['page_title'] = "Log View Band"; - $data['filter'] .= " and Band ".$band; - break; + $data['filter'] = "Call " . $call; + switch ($band) { + case 'All': + $data['page_title'] = "Log View All Bands"; + $data['filter'] .= " and Band All"; + break; + case 'SAT': + $data['page_title'] = "Log View SAT"; + $data['filter'] .= " and Band SAT"; + break; + default: + $data['page_title'] = "Log View Band"; + $data['filter'] .= " and Band " . $band; + break; } if ($band == "SAT") { - switch($leogeo) { - case 'both': $data['filter'] .= " and GEO/LEO"; - break; - case 'leo': $data['filter'] .= " and LEO"; - break; - case 'geo': $data['filter'] .= " and GEO"; - break; + switch ($leogeo) { + case 'both': + $data['filter'] .= " and GEO/LEO"; + break; + case 'leo': + $data['filter'] .= " and LEO"; + break; + case 'geo': + $data['filter'] .= " and GEO"; + break; } } $this->load->view('activators/details', $data); } - } diff --git a/application/models/Activators_model.php b/application/models/Activators_model.php index a3585715d..d2e81d961 100644 --- a/application/models/Activators_model.php +++ b/application/models/Activators_model.php @@ -3,115 +3,115 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class Activators_model extends CI_Model { - function get_activators($band, $mincount, $leogeo) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + function get_activators($band, $mincount, $leogeo) + { + $CI = &get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if ($mincount == '' || $mincount == 0 || ! is_numeric($mincount)) { + if ($mincount == '' || $mincount == 0 || !is_numeric($mincount)) { $mincount = 2; } - if (!$logbooks_locations_array) { - return null; - } + if (!$logbooks_locations_array) { + return null; + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; - $sql = "select COL_CALL as `call`, COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count`, GROUP_CONCAT(DISTINCT SUBSTR(`COL_GRIDSQUARE`,1,4) ORDER BY `COL_GRIDSQUARE` SEPARATOR ', ') AS `grids` from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; - if ($band != 'All') { - if ($band == 'SAT') { - switch ($leogeo) { - case 'both' : + $sql = "select COL_CALL as `call`, COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count`, GROUP_CONCAT(DISTINCT SUBSTR(`COL_GRIDSQUARE`,1,4) ORDER BY `COL_GRIDSQUARE` SEPARATOR ', ') AS `grids` from " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ")"; + if ($band != 'All') { + if ($band == 'SAT') { + switch ($leogeo) { + case 'both': $sql .= " and col_prop_mode ='" . $band . "'"; break; - case 'leo' : + case 'leo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name != 'QO-100'"; break; - case 'geo' : + case 'geo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name = 'QO-100'"; break; - default : + default: $sql .= " and col_prop_mode ='" . $band . "'"; break; - } } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and COL_BAND ='" . $band . "'"; - } - } - $sql .= " AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` HAVING `count` >= ".$mincount." ORDER BY `count` DESC;"; + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and COL_BAND ='" . $band . "'"; + } + } + $sql .= " AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` HAVING `count` >= " . $mincount . " ORDER BY `count` DESC;"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - return $query->result(); - } + return $query->result(); + } - function get_activators_vucc($band, $leogeo) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + function get_activators_vucc($band, $leogeo) + { + $CI = &get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if (!$logbooks_locations_array) { - return null; - } + if (!$logbooks_locations_array) { + return null; + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; - $sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(COL_VUCC_GRIDS) AS `vucc_grids` FROM ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ")"; - if ($band != 'All') { - if ($band == 'SAT') { - switch ($leogeo) { - case 'both' : + $sql = "SELECT DISTINCT COL_CALL AS `call`, GROUP_CONCAT(COL_VUCC_GRIDS) AS `vucc_grids` FROM " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ")"; + if ($band != 'All') { + if ($band == 'SAT') { + switch ($leogeo) { + case 'both': $sql .= " and col_prop_mode ='" . $band . "'"; break; - case 'leo' : + case 'leo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name != 'QO-100'"; break; - case 'geo' : + case 'geo': $sql .= " and col_prop_mode = '" . $band . "'"; $sql .= " and col_sat_name = 'QO-100'"; break; - default : + default: $sql .= " and col_prop_mode ='" . $band . "'"; break; - } } - else { - $sql .= " and col_prop_mode !='SAT'"; - $sql .= " and COL_BAND ='" . $band . "'"; - } - } + } else { + $sql .= " and col_prop_mode !='SAT'"; + $sql .= " and COL_BAND ='" . $band . "'"; + } + } $sql .= " AND COL_VUCC_GRIDS != '' GROUP BY COL_CALL;"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - return $query->result(); - } - function get_max_activated_grids() { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + return $query->result(); + } + function get_max_activated_grids() + { + $CI = &get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if (!$logbooks_locations_array) { - return array(); - } + if (!$logbooks_locations_array) { + return array(); + } - $location_list = "'".implode("','",$logbooks_locations_array)."'"; + $location_list = "'" . implode("','", $logbooks_locations_array) . "'"; - // Get max no of activated grids of single operator - $data = $this->db->query( - "select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" - ); - foreach($data->result() as $row){ - $max = $row->count; - } - - return ($max ?? 0); - } + // Get max no of activated grids of single operator + $data = $this->db->query( + "select COUNT(DISTINCT(SUBSTR(COL_GRIDSQUARE,1,4))) AS `count` from " . $this->config->item('table_name') . " WHERE station_id in (" . $location_list . ") AND `COL_GRIDSQUARE` != '' GROUP BY `COL_CALL` ORDER BY `count` DESC LIMIT 1" + ); + foreach ($data->result() as $row) { + $max = $row->count; + } + return ($max ?? 0); + } } diff --git a/application/views/activators/index.php b/application/views/activators/index.php index bcc6041b2..8ecedd01a 100644 --- a/application/views/activators/index.php +++ b/application/views/activators/index.php @@ -3,59 +3,59 @@
-
- -
- -
-
-
- -
- -
-
-
- -
- -
- -
- -
- -
- -
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+
- session->userdata('user_date_format')) { + if ($this->session->userdata('user_date_format')) { // If Logged in and session exists $custom_date_format = $this->session->userdata('user_date_format'); } else { @@ -63,19 +63,18 @@ $custom_date_format = $this->config->item('qso_date_format'); } ?> - call] = $line->vucc_grids; - } + foreach ($activators_vucc_array as $line) { + $vucc_grids[$line->call] = $line->vucc_grids; + } } - if( $this->input->post('band') != NULL) { + if ($this->input->post('band') != NULL) { if ($activators_array) { $result = write_activators($activators_array, $vucc_grids, $custom_date_format, $this->input->post('band'), $this->input->post('leogeo')); - } - else { + } else { echo ''; } } @@ -86,12 +85,13 @@ @@ -113,16 +113,16 @@ function write_activators($activators_array, $vucc_grids, $custom_date_format, $ $grids = $line->grids; $count = $line->count; if (array_key_exists($line->call, $vucc_grids)) { - foreach(explode(',', $vucc_grids[$line->call]) as $vgrid) { - if(!strpos($grids, $vgrid)) { - $grids .= ','.$vgrid; - } - } - $grids = str_replace(' ', '', $grids); - $grid_array = explode(',', $grids); - sort($grid_array); - $count = count($grid_array); - $grids = implode(', ', $grid_array); + foreach (explode(',', $vucc_grids[$line->call]) as $vgrid) { + if (!strpos($grids, $vgrid)) { + $grids .= ',' . $vgrid; + } + } + $grids = str_replace(' ', '', $grids); + $grid_array = explode(',', $grids); + sort($grid_array); + $count = count($grid_array); + $grids = implode(', ', $grid_array); } array_push($activators, array($count, $call, $grids)); } @@ -130,11 +130,11 @@ function write_activators($activators_array, $vucc_grids, $custom_date_format, $ foreach ($activators as $line) { echo ' ' . $i++ . ' - '.$line[1].' - '.$line[0].' - '.$line[2].' - - + ' . $line[1] . ' + ' . $line[0] . ' + ' . $line[2] . ' + + '; } echo '
'; From c9a3e1d9e23db277c392e6c1385c25cf0fe10bc0 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 24 May 2024 20:50:17 +0200 Subject: [PATCH 02/19] $CI to $this --- application/models/Activators_model.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/application/models/Activators_model.php b/application/models/Activators_model.php index d2e81d961..3a4c1cee2 100644 --- a/application/models/Activators_model.php +++ b/application/models/Activators_model.php @@ -5,9 +5,8 @@ class Activators_model extends CI_Model { function get_activators($band, $mincount, $leogeo) { - $CI = &get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if ($mincount == '' || $mincount == 0 || !is_numeric($mincount)) { $mincount = 2; @@ -52,9 +51,8 @@ class Activators_model extends CI_Model function get_activators_vucc($band, $leogeo) { - $CI = &get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { return null; @@ -94,9 +92,8 @@ class Activators_model extends CI_Model } function get_max_activated_grids() { - $CI = &get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { return array(); From 6ea710ff27d57ff05d1089451a27aa3a5e63466b Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 24 May 2024 21:36:46 +0200 Subject: [PATCH 03/19] move js to a dedicated file --- application/controllers/Activators.php | 8 ++- application/views/activators/index.php | 2 +- application/views/interface_assets/footer.php | 70 +------------------ assets/js/sections/activators.js | 62 ++++++++++++++++ 4 files changed, 70 insertions(+), 72 deletions(-) create mode 100644 assets/js/sections/activators.js diff --git a/application/controllers/Activators.php b/application/controllers/Activators.php index 73d01fe96..b2d056a94 100644 --- a/application/controllers/Activators.php +++ b/application/controllers/Activators.php @@ -17,7 +17,6 @@ class Activators extends CI_Controller public function index() { - // Render Page $data['page_title'] = "Gridsquare Activators"; $this->load->model('Activators_model'); @@ -36,9 +35,14 @@ class Activators extends CI_Controller $data['activators_vucc_array'] = $this->Activators_model->get_activators_vucc($band, $this->input->post('leogeo')); $data['bandselect'] = $band; + $footerData = []; + $footerData['scripts'] = [ + 'assets/js/sections/activators.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/activators.js")), + ]; + $this->load->view('interface_assets/header', $data); $this->load->view('activators/index'); - $this->load->view('interface_assets/footer'); + $this->load->view('interface_assets/footer', $footerData); } public function details() diff --git a/application/views/activators/index.php b/application/views/activators/index.php index 8ecedd01a..7bbee459d 100644 --- a/application/views/activators/index.php +++ b/application/views/activators/index.php @@ -16,7 +16,7 @@ -
+ -optionslib->get_option('public_maps') == 'true') { ?> +optionslib->get_option('public_maps') ?? 'true' == 'true') { ?>
diff --git a/application/views/visitor/layout/header.php b/application/views/visitor/layout/header.php index 801277900..c913f8c54 100644 --- a/application/views/visitor/layout/header.php +++ b/application/views/visitor/layout/header.php @@ -62,7 +62,7 @@
-optionslib->get_option('public_maps') ?? 'true' == 'true') { ?> -
+optionslib->get_option('public_maps') ?? 'true'; + if ($public_maps_option == 'true') { ?> +
diff --git a/application/views/visitor/layout/header.php b/application/views/visitor/layout/header.php index c913f8c54..1b395cd73 100644 --- a/application/views/visitor/layout/header.php +++ b/application/views/visitor/layout/header.php @@ -62,7 +62,8 @@