From 0e684a236d0e1b980b40fe3a763a7d79a2bdea00 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 22 Aug 2025 05:44:00 +0000 Subject: [PATCH] Take care of mode at cluster --- application/models/Dxcluster_model.php | 45 +++++++++++++++----------- application/models/Logbook_model.php | 25 +++++++++++--- application/models/Modes.php | 44 ++++++++++++++++++++++++- 3 files changed, 91 insertions(+), 23 deletions(-) diff --git a/application/models/Dxcluster_model.php b/application/models/Dxcluster_model.php index b5f431dc9..0b6284de9 100644 --- a/application/models/Dxcluster_model.php +++ b/application/models/Dxcluster_model.php @@ -4,12 +4,13 @@ use Wavelog\Dxcc\Dxcc; class Dxcluster_model extends CI_Model { - protected $bandedges = []; + protected $bandedges = []; - public function __construct() { + public function __construct() { + $this->load->Model('Modes'); $this->db->where('bandedges.userid', $this->session->userdata('user_id')); $query = $this->db->get('bandedges'); - $result = $query->result_array(); + $result = $query->result_array(); if ($result) { $this->bandedges = $result; @@ -19,7 +20,7 @@ class Dxcluster_model extends CI_Model { $query = $this->db->get('bandedges'); $this->bandedges = $query->result_array(); } - } + } public function dxc_spotlist($band = '20m', $maxage = 60, $de = '', $mode = 'All') { $this->load->helper(array('psr4_autoloader')); @@ -98,12 +99,12 @@ class Dxcluster_model extends CI_Model { } if ( ($de != '') && ($de != 'Any') && (property_exists($singlespot->dxcc_spotter,'cont')) ){ // If we have a "de continent" and a filter-wish filter on that if (strtolower($de) == strtolower($singlespot->dxcc_spotter->cont ?? '')) { - $singlespot->worked_dxcc = ($this->logbook_model->check_if_dxcc_worked_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->cnfmd_dxcc = ($this->logbook_model->check_if_dxcc_cnfmd_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->worked_call = ($this->logbook_model->check_if_callsign_worked_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->cnfmd_call = ($this->logbook_model->check_if_callsign_cnfmd_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->cnfmd_continent = ($this->check_if_continent_cnfmd_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->worked_continent = ($this->check_if_continent_cnfmd_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band) >= 1); + $singlespot->worked_dxcc = ($this->logbook_model->check_if_dxcc_worked_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->cnfmd_dxcc = ($this->logbook_model->check_if_dxcc_cnfmd_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->worked_call = ($this->logbook_model->check_if_callsign_worked_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->cnfmd_call = ($this->logbook_model->check_if_callsign_cnfmd_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->cnfmd_continent = ($this->check_if_continent_cnfmd_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->worked_continent = ($this->check_if_continent_cnfmd_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); if ($singlespot->worked_call) { $singlespot->last_wked=$this->logbook_model->last_worked_callsign_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band)[0]; if ($this->session->userdata('user_date_format')) { @@ -116,12 +117,12 @@ class Dxcluster_model extends CI_Model { array_push($spotsout,$singlespot); } } else { // No de continent? No Filter --> Just push - $singlespot->worked_dxcc = ($this->logbook_model->check_if_dxcc_worked_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->worked_call = ($this->logbook_model->check_if_callsign_worked_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->cnfmd_dxcc = ($this->logbook_model->check_if_dxcc_cnfmd_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->cnfmd_call = ($this->logbook_model->check_if_callsign_cnfmd_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->cnfmd_continent = ($this->check_if_continent_cnfmd_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band) >= 1); - $singlespot->worked_continent = ($this->check_if_continent_worked_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band) >= 1); + $singlespot->worked_dxcc = ($this->logbook_model->check_if_dxcc_worked_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->worked_call = ($this->logbook_model->check_if_callsign_worked_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->cnfmd_dxcc = ($this->logbook_model->check_if_dxcc_cnfmd_in_logbook($singlespot->dxcc_spotted->dxcc_id, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->cnfmd_call = ($this->logbook_model->check_if_callsign_cnfmd_in_logbook($singlespot->spotted, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->cnfmd_continent = ($this->check_if_continent_cnfmd_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); + $singlespot->worked_continent = ($this->check_if_continent_worked_in_logbook($singlespot->dxcc_spotted->cont, $logbooks_locations_array, $singlespot->band, $singlespot->mode) >= 1); array_push($spotsout,$singlespot); } } @@ -250,7 +251,7 @@ class Dxcluster_model extends CI_Model { } } - function check_if_continent_worked_in_logbook($cont, $StationLocationsArray = null, $band = null) { + function check_if_continent_worked_in_logbook($cont, $StationLocationsArray = null, $band = null, $mode = null) { if ($StationLocationsArray == null) { $this->load->model('logbooks_model'); @@ -263,6 +264,10 @@ class Dxcluster_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_CONT', $cont); + if (isset($mode)) { + $this->db->where(" COL_MODE in ".$this->Modes->get_modes_from_qrgmode($mode,true)); + } + $band = ($band == 'All') ? null : $band; if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); @@ -276,7 +281,7 @@ class Dxcluster_model extends CI_Model { return $query->num_rows(); } - function check_if_continent_cnfmd_in_logbook($cont, $StationLocationsArray = null, $band = null) { + function check_if_continent_cnfmd_in_logbook($cont, $StationLocationsArray = null, $band = null, $mode = null) { if ($StationLocationsArray == null) { $this->load->model('logbooks_model'); @@ -315,6 +320,10 @@ class Dxcluster_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_CONT', $cont); + if (isset($mode)) { + $this->db->where(" COL_MODE in ".$this->Modes->get_modes_from_qrgmode($mode,true)); + } + $band = ($band == 'All') ? null : $band; if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 2912c9108..931064502 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -5,6 +5,7 @@ class Logbook_model extends CI_Model { private $station_result = []; public function __construct() { $this->oop_populate_modes(); + $this->load->Model('Modes'); } private $oop_modes = []; @@ -2375,7 +2376,7 @@ class Logbook_model extends CI_Model { } } - function check_if_callsign_cnfmd_in_logbook($callsign, $StationLocationsArray = null, $band = null) { + function check_if_callsign_cnfmd_in_logbook($callsign, $StationLocationsArray = null, $band = null, $mode = null) { if ($StationLocationsArray == null) { $this->load->model('logbooks_model'); @@ -2414,6 +2415,10 @@ class Logbook_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_CALL', $callsign); + if (isset($mode)) { + $this->db->where(" COL_MODE in ".$this->Modes->get_modes_from_qrgmode($mode,true)); + } + $band = ($band == 'All') ? null : $band; if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); @@ -2459,7 +2464,7 @@ class Logbook_model extends CI_Model { return $query->result(); } - function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = null, $band = null) { + function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray = null, $band = null, $mode = null) { if ($StationLocationsArray == null) { $this->load->model('logbooks_model'); @@ -2472,6 +2477,10 @@ class Logbook_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_CALL', $callsign); + if (isset($mode)) { + $this->db->where(" COL_MODE in ".$this->Modes->get_modes_from_qrgmode($mode,true)); + } + $band = ($band == 'All') ? null : $band; if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); @@ -2485,7 +2494,7 @@ class Logbook_model extends CI_Model { return $query->num_rows(); } - function check_if_dxcc_worked_in_logbook($dxcc, $StationLocationsArray = null, $band = null) { + function check_if_dxcc_worked_in_logbook($dxcc, $StationLocationsArray = null, $band = null, $mode = null) { if ($StationLocationsArray == null) { $this->load->model('logbooks_model'); @@ -2498,6 +2507,10 @@ class Logbook_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_DXCC', $dxcc); + if (isset($mode)) { + $this->db->where(" COL_MODE in ".$this->Modes->get_modes_from_qrgmode($mode,true)); + } + $band = ($band == 'All') ? null : $band; if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); @@ -2576,7 +2589,7 @@ class Logbook_model extends CI_Model { } - function check_if_dxcc_cnfmd_in_logbook($dxcc, $StationLocationsArray = null, $band = null) { + function check_if_dxcc_cnfmd_in_logbook($dxcc, $StationLocationsArray = null, $band = null, $mode = null) { if ($StationLocationsArray == null) { $this->load->model('logbooks_model'); @@ -2615,6 +2628,10 @@ class Logbook_model extends CI_Model { $this->db->where_in('station_id', $logbooks_locations_array); $this->db->where('COL_DXCC', $dxcc); + if (isset($mode)) { + $this->db->where(" COL_MODE in ".$this->Modes->get_modes_from_qrgmode($mode,true)); + } + $band = ($band == 'All') ? null : $band; if ($band != null && $band != 'SAT') { $this->db->where('COL_BAND', $band); diff --git a/application/models/Modes.php b/application/models/Modes.php index 66f40ac9b..07c34dc3e 100644 --- a/application/models/Modes.php +++ b/application/models/Modes.php @@ -15,6 +15,48 @@ class Modes extends CI_Model { return $this->db->get('adif_modes'); } + function get_modes_from_qrgmode($qrgmode = '', $translate_from_ui = false) { + // Clean ID + $bindings=[]; + if ($translate_from_ui) { + if ($qrgmode == 'digi') { + $bindings[] = 'DATA'; + } elseif ($qrgmode == 'cw') { + $bindings[] = 'CW'; + } elseif ($qrgmode == 'phone') { + $bindings[] = 'SSB'; + } else { + $bindings[]=''; + } + } else { + $bindings[]=$this->security->xss_clean($qrgmode); + } + + $query = $this->db->query('select distinct mode from adif_modes where qrgmode = ?', $bindings); + if ($query->num_rows() > 0) { + $modes = []; + foreach ($query->result() as $row) { + $modes[] = "'".$this->security->xss_clean($row->mode)."'"; + } + return '('.implode(',', $modes).')'; + } else { + return '()'; + } + } + + function get_qrgmode_from_mode($mode = '') { + // Clean ID + $bindings=[]; + $bindings[] = ($this->security->xss_clean($mode) ?? ''); + + $query = $this->db->query('select qrgmode from adif_modes where mode = ?', $bindings); + if ($query->num_rows() > 0) { + return $query->row()->QRGMODE; + } else { + return ''; + } + } + function mode($id) { // Clean ID $clean_id = $this->security->xss_clean($id); @@ -118,4 +160,4 @@ class Modes extends CI_Model { } -?> \ No newline at end of file +?>