diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index c69d50cc..b3fe1225 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -435,7 +435,7 @@ class Lotw extends CI_Controller { // Read Cert Data $certdata= openssl_x509_parse($results['cert'],0); - + // Store Variables $data['issued_callsign'] = $certdata['subject']['undefined']; $data['issued_name'] = $certdata['subject']['commonName']; @@ -630,14 +630,22 @@ class Lotw extends CI_Controller { $query = $this->user_model->get_all_lotw_users(); if ($query->num_rows() >= 1) { - $results=''; + $result = ''; foreach ($query->result() as $user) { if ( ($sync_user_id != null) && ($sync_user_id != $user->user_id) ) { continue; } + // Validate that LoTW credentials are not empty + // TODO: We don't actually see the error message + if ($user->user_lotw_password == '') { + $result = "You have not defined your ARRL LoTW credentials!"; + continue; + } + $config['upload_path'] = './uploads/'; $file = $config['upload_path'] . 'lotwreport_download.adi'; if (file_exists($file) && ! is_writable($file)) { - $result.= "Temporary download file ".$file." is not writable. Aborting!"; + $result = "Temporary download file ".$file." is not writable. Aborting!"; + continue; } // Get credentials for LoTW @@ -649,14 +657,7 @@ class Lotw extends CI_Controller { $q = $query->row(); $lotw_url = $q->lotw_download_url; - // Validate that LoTW credentials are not empty - // TODO: We don't actually see the error message - if ($data['user_lotw_name'] == '' || $data['user_lotw_password'] == '') - { - echo "You have not defined your ARRL LoTW credentials!"; - } - - $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($user->user_id))); + $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($user->user_id))); // Build URL for LoTW report file $lotw_url .= "?"; @@ -668,19 +669,22 @@ class Lotw extends CI_Controller { $lotw_url .= "$lotw_last_qsl_date"; if (! is_writable(dirname($file))) { - $results.= "Temporary download directory ".dirname($file)." is not writable. Aborting!"; + $result = "Temporary download directory ".dirname($file)." is not writable. Aborting!"; continue; } file_put_contents($file, file_get_contents($lotw_url)); if (file_get_contents($file, false, null, 0, 39) != "ARRL Logbook of the World Status Report") { - $results.= "LoTW downloading failed for User ".$data['user_lotw_name']." either due to it being down or incorrect logins."; + $result = "LoTW downloading failed for User ".$data['user_lotw_name']." either due to it being down or incorrect logins."; continue; } ini_set('memory_limit', '-1'); - $results.= $this->loadFromFile($file, false); + $result = $this->loadFromFile($file, false); } - return $results; + if ($result == '') { + $result = "You have not defined your ARRL LoTW credentials!"; + } + return $result; } else { return "No LoTW User details found to carry out matches."; } @@ -740,9 +744,9 @@ class Lotw extends CI_Controller { $lotw_url .= "&qso_qslsince="; $lotw_url .= "$lotw_last_qsl_date"; - // Only pull back entries that belong to this callsign - $lotw_call = $this->session->userdata('user_callsign'); - $lotw_url .= "&qso_owncall=$lotw_call"; + if ($this->input->post('callsign') != '0') { + $lotw_url .= "&qso_owncall=".$this->input->post('callsign'); + } file_put_contents($file, file_get_contents($lotw_url)); @@ -755,9 +759,11 @@ class Lotw extends CI_Controller { { $data['error'] = $this->upload->display_errors(); + $this->load->model('Stations'); + $data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id')); $this->load->view('interface_assets/header', $data); - $this->load->view('lotw/import'); + $this->load->view('lotw/import', $data); $this->load->view('interface_assets/footer'); } else diff --git a/application/language/bulgarian/lotw_lang.php b/application/language/bulgarian/lotw_lang.php index eda6a36d..feb31524 100644 --- a/application/language/bulgarian/lotw_lang.php +++ b/application/language/bulgarian/lotw_lang.php @@ -34,6 +34,7 @@ $lang['lotw_upload_exported_adif_file_from_lotw'] = 'Upload the Exported ADIF fi $lang['lotw_upload_type_must_be_adi'] = 'Log files must have the file type .adi'; $lang['lotw_pull_lotw_data_for_me'] = 'Pull LoTW data for me'; +$lang['lotw_select_callsign'] = 'Select callsign to pull LoTW confirmations for'; $lang['lotw_report_download_overview_helptext'] = 'Cloudlog will use the LoTW username and password stored in your user profile to download a report from LoTW for you. The report Cloudlog downloads will have all confirmations since chosen date, or since your last LoTW confirmation (fetched from your log), up until now.'; diff --git a/application/language/chinese_simplified/lotw_lang.php b/application/language/chinese_simplified/lotw_lang.php index 7d788259..4ffcc62e 100644 --- a/application/language/chinese_simplified/lotw_lang.php +++ b/application/language/chinese_simplified/lotw_lang.php @@ -34,6 +34,7 @@ $lang['lotw_upload_exported_adif_file_from_lotw'] = '下载从 LoTW session->userdata('user_id'); // Fallback to session-uid, if userid is omitted } $this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end'); @@ -33,6 +33,15 @@ class Stations extends CI_Model { return $this->db->get('station_profile'); } + function callsigns_of_user($userid = null) { + if ($userid == null) { + $userid=$this->session->userdata('user_id'); // Fallback to session-uid, if userid is omitted + } + $this->db->select('distinct(station_profile.station_callsign) as callsign'); + $this->db->where('user_id', $userid); + return $this->db->get('station_profile'); + } + function profile($id) { // Clean ID $clean_id = $this->security->xss_clean($id); diff --git a/application/views/lotw/import.php b/application/views/lotw/import.php index d69e98ba..780f450e 100644 --- a/application/views/lotw/import.php +++ b/application/views/lotw/import.php @@ -1,9 +1,9 @@

-

- +
-
+
load->view('layout/messages'); ?> @@ -17,12 +17,13 @@

+
-
+



@@ -31,6 +32,7 @@
+

:

@@ -38,12 +40,28 @@

+
+
+ + result() as $call) { + $options[$call->callsign] = $call->callsign; + } + ksort($options); + array_unshift($options, 'All'); + echo form_dropdown('callsign', $options, 'All'); + ?> +
+
+
-

+

+
- + - +