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 e4f611cd..5cc2adf5 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'; @@ -52,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 dfb34e06..0e201627 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'; @@ -52,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..f4426314 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -63,6 +63,22 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { + session->userdata('user_id')) { ?> + LotwCert->lotw_cert_expired($this->session->userdata('user_id'), $current_date) == true) { ?> +