Only export QSOs which belong to user (ADI-Exp)

This commit is contained in:
int2001
2025-11-30 11:00:34 +00:00
parent d1b81f9845
commit 4683755e0d
2 changed files with 53 additions and 14 deletions

View File

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

View File

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