Take care of mode at cluster

This commit is contained in:
int2001
2025-08-22 05:44:00 +00:00
parent 14e3e36663
commit 0e684a236d
3 changed files with 91 additions and 23 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 {
}
?>
?>