From 4683755e0dbf94fee2d23e2b5c48369b65feac4a Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 30 Nov 2025 11:00:34 +0000 Subject: [PATCH] Only export QSOs which belong to user (ADI-Exp) --- application/controllers/Adif.php | 35 ++++++++++++++++++++++++-------- application/models/Adif_data.php | 32 +++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/application/controllers/Adif.php b/application/controllers/Adif.php index 95a9f7f8e..9114a510a 100644 --- a/application/controllers/Adif.php +++ b/application/controllers/Adif.php @@ -88,6 +88,7 @@ class adif extends CI_Controller { // Export all QSO Data in ASC Order of Date. public function exportall() { // Set memory limit to unlimited to allow heavy usage + $this->require_tab_access('export'); ini_set('memory_limit', '-1'); $this->load->model('adif_data'); @@ -101,11 +102,18 @@ class adif extends CI_Controller { // Export all QSO Data in ASC Order of Date. public function exportsat() { // Set memory limit to unlimited to allow heavy usage + $this->require_tab_access('export'); ini_set('memory_limit', '-1'); $this->load->model('adif_data'); - $data['qsos'] = $this->adif_data->sat_all(); + if (clubaccess_check(6) && !clubaccess_check(9)) { + $onlyop=($this->session->userdata('operator_callsign') ?? ''); + } else { + $onlyop=null; + } + + $data['qsos'] = $this->adif_data->sat_all($onlyop); $this->load->view('adif/data/exportsat', $data); } @@ -113,11 +121,18 @@ class adif extends CI_Controller { // Export all QSO Data in ASC Order of Date. public function exportsatlotw() { // Set memory limit to unlimited to allow heavy usage + $this->require_tab_access('export'); ini_set('memory_limit', '-1'); + if (clubaccess_check(6) && !clubaccess_check(9)) { + $onlyop=($this->session->userdata('operator_callsign') ?? ''); + } else { + $onlyop=null; + } + $this->load->model('adif_data'); - $data['qsos'] = $this->adif_data->satellte_lotw(); + $data['qsos'] = $this->adif_data->satellte_lotw($onlyop); $this->load->view('adif/data/exportsat', $data); } @@ -140,14 +155,19 @@ class adif extends CI_Controller { $exportLotw = false; } - $data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id, $exportLotw); + if (clubaccess_check(6) && !clubaccess_check(9)) { + $onlyop=($this->session->userdata('operator_callsign') ?? ''); + } else { + $onlyop=null; + } + + $data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id, $exportLotw, $onlyop); $this->load->view('adif/data/exportall', $data); - if ($this->input->post('markLotw') == 1) { - foreach ($data['qsos']->result() as $qso) - { + if ((clubaccess_check(9)) && ($this->input->post('markLotw') == 1)) { // Only allow marking if clubofficer or regular user! + foreach ($data['qsos']->result() as $qso) { $this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY); } } @@ -186,8 +206,7 @@ class adif extends CI_Controller { $this->load->view('adif/data/exportall', $data); - foreach ($data['qsos']->result() as $qso) - { + foreach ($data['qsos']->result() as $qso) { $this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY); } } diff --git a/application/models/Adif_data.php b/application/models/Adif_data.php index 6dc710c60..e34845546 100644 --- a/application/models/Adif_data.php +++ b/application/models/Adif_data.php @@ -2,7 +2,7 @@ class adif_data extends CI_Model { - function export_all($api_key = null,$from = null, $to = null, $exportLotw = false) { + function export_all($api_key = null,$from = null, $to = null, $exportLotw = false, $onlyop = null) { $this->load->model('logbooks_model'); if ($api_key != null) { $this->load->model('api_model'); @@ -25,6 +25,9 @@ class adif_data extends CI_Model { if ($to) { $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= ",$to); } + if ($onlyop) { + $this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop); + } if ($exportLotw) { $this->db->group_start(); $this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'"); @@ -76,7 +79,7 @@ class adif_data extends CI_Model { return $query; } - function sat_all() { + function sat_all($onlyop = null) { $this->load->model('stations'); $active_station_id = $this->stations->find_active(); @@ -85,6 +88,10 @@ class adif_data extends CI_Model { $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); $this->db->where($this->config->item('table_name').'.COL_PROP_MODE', 'SAT'); + if ($onlyop) { + $this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop); + } + $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); @@ -93,7 +100,7 @@ class adif_data extends CI_Model { return $this->db->get(); } - function satellte_lotw() { + function satellte_lotw($onlyop = null) { $this->load->model('stations'); $active_station_id = $this->stations->find_active(); @@ -102,6 +109,10 @@ class adif_data extends CI_Model { $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); $this->db->where($this->config->item('table_name').'.COL_PROP_MODE', 'SAT'); + if ($onlyop) { + $this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop); + } + $where = $this->config->item('table_name').".COL_LOTW_QSLRDATE IS NOT NULL"; $this->db->where($where); @@ -114,7 +125,7 @@ class adif_data extends CI_Model { return $this->db->get(); } - function export_custom($from, $to, $station_id, $exportLotw = false) { + function export_custom($from, $to, $station_id, $exportLotw = false, $onlyop = null) { // be sure that station belongs to user $this->load->model('Stations'); if ($station_id == 0) { @@ -135,6 +146,9 @@ class adif_data extends CI_Model { if ($to) { $this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= ",$to); } + if ($onlyop) { + $this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop); + } if ($exportLotw) { $this->db->group_start(); $this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'"); @@ -151,7 +165,7 @@ class adif_data extends CI_Model { } } - function export_past_id($station_id, $fetchfromid, $limit) { + function export_past_id($station_id, $fetchfromid, $limit, $onlyop = null) { //create query $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*, dxcc_entities.name as station_country'); $this->db->from($this->config->item('table_name')); @@ -160,6 +174,9 @@ class adif_data extends CI_Model { $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "ASC"); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); $this->db->join('dxcc_entities', 'station_profile.station_dxcc = dxcc_entities.adif', 'left outer'); + if ($onlyop) { + $this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop); + } $this->db->order_by("COL_PRIMARY_KEY", "ASC"); if ($limit > -1) { @@ -170,7 +187,7 @@ class adif_data extends CI_Model { return $this->db->get(); } - function export_lotw() { + function export_lotw($onlyop = null) { $this->load->model('stations'); $active_station_id = $this->stations->find_active(); @@ -178,6 +195,9 @@ class adif_data extends CI_Model { $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*, dxcc_entities.name as station_country'); $this->db->from($this->config->item('table_name')); $this->db->where($this->config->item('table_name').'.station_id', $active_station_id); + if ($onlyop) { + $this->db->where("upper(".$this->config->item('table_name').".col_operator)",$onlyop); + } $this->db->group_start(); $this->db->where($this->config->item('table_name').".COL_LOTW_QSL_SENT != 'Y'"); $this->db->or_where($this->config->item('table_name').".COL_LOTW_QSL_SENT", NULL);