From 50190eb4eb6b3a0f48a423193e32e89712fe8a42 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 23 Dec 2022 10:53:46 +0100 Subject: [PATCH 1/3] Add warning grace time notification for LotW certs --- application/language/english/lotw_lang.php | 1 + application/language/german/lotw_lang.php | 1 + application/views/lotw_views/index.php | 9 ++++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/application/language/english/lotw_lang.php b/application/language/english/lotw_lang.php index e4f611cd..240f7cec 100644 --- a/application/language/english/lotw_lang.php +++ b/application/language/english/lotw_lang.php @@ -22,6 +22,7 @@ $lang['lotw_status'] = 'Status'; $lang['lotw_options'] = 'Options'; $lang['lotw_valid'] = 'Valid'; $lang['lotw_expired'] = 'Expired'; +$lang['lotw_expiring'] = 'Expiring'; $lang['lotw_not_synced'] = 'Not Synced'; $lang['lotw_certificate_dxcc'] = 'Certificate DXCC'; diff --git a/application/language/german/lotw_lang.php b/application/language/german/lotw_lang.php index dfb34e06..88413da8 100644 --- a/application/language/german/lotw_lang.php +++ b/application/language/german/lotw_lang.php @@ -22,6 +22,7 @@ $lang['lotw_status'] = 'Status'; $lang['lotw_options'] = 'Optionen'; $lang['lotw_valid'] = 'Gültig'; $lang['lotw_expired'] = 'Abgelaufen'; +$lang['lotw_expiring'] = 'Läuft ab'; $lang['lotw_not_synced'] = 'Nicht synchronisiert'; $lang['lotw_certificate_dxcc'] = 'Zertifikats-DXCC'; diff --git a/application/views/lotw_views/index.php b/application/views/lotw_views/index.php index 023fceca..db129248 100644 --- a/application/views/lotw_views/index.php +++ b/application/views/lotw_views/index.php @@ -76,11 +76,14 @@ + date_expires.'-10 days')); ?> - date_expires) { ?> - lang->line('lotw_valid'); ?> - + $row->date_expires) { ?> lang->line('lotw_expired'); ?> + date_expires && $current_date > $warning_date) { ?> + lang->line('lotw_expiring'); ?> + + lang->line('lotw_valid'); ?> last_upload) { ?> From 33ed61409bdffee45aa8990f9a1b37be60f5ae56 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 23 Dec 2022 14:49:03 +0100 Subject: [PATCH 2/3] Show warnings on dashboard and set deadline to 30 days --- application/controllers/Dashboard.php | 8 ++++++- application/language/english/lotw_lang.php | 4 ++++ application/language/german/lotw_lang.php | 4 ++++ application/models/LotwCert.php | 25 ++++++++++++++++++++++ application/views/dashboard/index.php | 15 +++++++++++++ application/views/lotw_views/index.php | 2 +- 6 files changed, 56 insertions(+), 2 deletions(-) diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index b6ff000b..8da1c0a3 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -8,11 +8,17 @@ class Dashboard extends CI_Controller { if(ENVIRONMENT == 'development') { $this->output->enable_profiler(TRUE); } - + + // Load language files + $this->lang->load('lotw'); + // Database connections $this->load->model('logbook_model'); $this->load->model('user_model'); + // LotW infos + $this->load->model('LotwCert'); + if($this->optionslib->get_option('version2_trigger') == "false") { redirect('welcome'); } diff --git a/application/language/english/lotw_lang.php b/application/language/english/lotw_lang.php index 240f7cec..5cc2adf5 100644 --- a/application/language/english/lotw_lang.php +++ b/application/language/english/lotw_lang.php @@ -53,3 +53,7 @@ $lang['lotw_p12_export_step_three'] = 'Click "Save Callsign Certificate File" an $lang['lotw_p12_export_step_four'] = 'Upload File below.'; $lang['lotw_confirmed'] = 'This QSO is confirmed on LoTW'; + +// LotW Expiry +$lang['lotw_cert_expiring'] = 'At least one of your LotW certificates is about to expire!'; +$lang['lotw_cert_expired'] = 'At least one of your LotW certificates is expired!'; diff --git a/application/language/german/lotw_lang.php b/application/language/german/lotw_lang.php index 88413da8..0e201627 100644 --- a/application/language/german/lotw_lang.php +++ b/application/language/german/lotw_lang.php @@ -53,3 +53,7 @@ $lang['lotw_p12_export_step_three'] = 'Klick "Save Callsign Certificate File" un $lang['lotw_p12_export_step_four'] = 'Lade untenstehende Datei hoch.'; $lang['lotw_confirmed'] = 'Dieses QSO wurde via LotW bestätigt am'; + +// LotW Expiry +$lang['lotw_cert_expiring'] = 'Mindestens eines deiner LotW Zertifikate läuft bald ab!'; +$lang['lotw_cert_expired'] = 'Mindestens eines deiner LotW Zertifikate ist abgelaufen!'; diff --git a/application/models/LotwCert.php b/application/models/LotwCert.php index a9661493..238b3449 100644 --- a/application/models/LotwCert.php +++ b/application/models/LotwCert.php @@ -90,5 +90,30 @@ class LotwCert extends CI_Model { function empty_table($table) { $this->db->empty_table($table); } + + function lotw_cert_expired($user_id, $date) { + $array = array('user_id' => $user_id, 'date_expires <' => $date); + $this->db->where($array); + $query = $this->db->get('lotw_certs'); + + if ($query->num_rows() > 0) { + return true; + } else { + return false; + } + } + + function lotw_cert_expiring($user_id, $date) { + $array = array('user_id' => $user_id, 'DATE_SUB(date_expires, INTERVAL 30 DAY) <' => $date, 'date_expires >' => $date); + $this->db->where($array); + $query = $this->db->get('lotw_certs'); + + if ($query->num_rows() > 0) { + return true; + } else { + return false; + } + } + } ?> diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index d99945da..ce51b51a 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -63,6 +63,21 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { + + LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?> + + + + LotwCert->lotw_cert_expiring($this->session->userdata('user_id'), $current_date) == true) { ?> + + + diff --git a/application/views/lotw_views/index.php b/application/views/lotw_views/index.php index db129248..24b42e2f 100644 --- a/application/views/lotw_views/index.php +++ b/application/views/lotw_views/index.php @@ -76,7 +76,7 @@ - date_expires.'-10 days')); ?> + date_expires.'-30 days')); ?> $row->date_expires) { ?> lang->line('lotw_expired'); ?> From 4c9e65930d8352db1d57ad259357b1a72baed842 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 23 Dec 2022 14:56:40 +0100 Subject: [PATCH 3/3] Check for user_id before using it --- application/views/dashboard/index.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index ce51b51a..f4426314 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -63,19 +63,20 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { - - LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?> - - + session->userdata('user_id')) { ?> + LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?> + + - LotwCert->lotw_cert_expiring($this->session->userdata('user_id'), $current_date) == true) { ?> - + LotwCert->lotw_cert_expiring($this->session->userdata('user_id'), $current_date) == true) { ?> + +