From af9168989bb6748f4481ab13fb5739ca43e87c8b Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 4 Feb 2024 16:36:56 +0000 Subject: [PATCH] Fixed a few null-checks which will fail on fresh accounts --- application/controllers/Hrdlog.php | 8 +++++--- application/controllers/Lotw.php | 20 +++++++++---------- application/controllers/Qrz.php | 7 ++++--- application/models/Distances_model.php | 2 +- .../views/search/search_result_ajax.php | 2 +- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index e1544c0ae..934cd1b2e 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -165,10 +165,12 @@ class Hrdlog extends CI_Controller { $this->load->model('logbook_model'); - foreach ($data['qsos']->result() as $qso) + if (isset($data['qsos'])) { + foreach ($data['qsos']->result() as $qso) { - $this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY); - } + $this->logbook_model->mark_hrdlog_qsos_sent($qso->COL_PRIMARY_KEY); + } + } $this->load->view('interface_assets/header', $data); $this->load->view('hrdlog/mark_hrdlog', $data); diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 80859adc4..15a0adbb7 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -717,9 +717,9 @@ class Lotw extends CI_Controller { // Get credentials for LoTW $query = $this->user_model->get_by_id($this->session->userdata('user_id')); - $q = $query->row(); - $data['user_lotw_name'] = urlencode($q->user_lotw_name); - $data['user_lotw_password'] = urlencode($q->user_lotw_password); + $q = $query->row(); + $data['user_lotw_name'] = urlencode($q->user_lotw_name ?? ''); + $data['user_lotw_password'] = urlencode($q->user_lotw_password ?? ''); // Get URL for downloading LoTW $query = $query = $this->db->query('SELECT lotw_download_url FROM config'); @@ -733,15 +733,15 @@ class Lotw extends CI_Controller { $this->session->set_flashdata('warning', 'You have not defined your ARRL LoTW credentials!'); redirect('lotw/import'); } - $customDate = $this->input->post('from'); + $customDate = $this->input->post('from'); if ($customDate != NULL) { - $lotw_last_qsl_date = date($customDate); - } - else { - // Query the logbook to determine when the last LoTW confirmation was - $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($this->session->userdata['user_id']))); - } + $lotw_last_qsl_date = date($customDate); + } + else { + // Query the logbook to determine when the last LoTW confirmation was + $lotw_last_qsl_date = date('Y-m-d', strtotime($this->logbook_model->lotw_last_qsl_date($this->session->userdata['user_id']))); + } // Build URL for LoTW report file $lotw_url .= "?"; diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php index c2ea63fdc..290df4594 100644 --- a/application/controllers/Qrz.php +++ b/application/controllers/Qrz.php @@ -170,9 +170,10 @@ class Qrz extends CI_Controller { $this->load->model('logbook_model'); - foreach ($data['qsos']->result() as $qso) - { - $this->logbook_model->mark_qrz_qsos_sent($qso->COL_PRIMARY_KEY); + if (isset($data['qsos'])) { + foreach ($data['qsos']->result() as $qso) { + $this->logbook_model->mark_qrz_qsos_sent($qso->COL_PRIMARY_KEY); + } } $this->load->view('interface_assets/header', $data); diff --git a/application/models/Distances_model.php b/application/models/Distances_model.php index 3aa17c0c0..2a0bd27fd 100644 --- a/application/models/Distances_model.php +++ b/application/models/Distances_model.php @@ -162,7 +162,7 @@ class Distances_model extends CI_Model 'Callsign' => '', 'Grid' => '', 'Distance' => '', - 'Qsos' => '', + 'Qsos' => 0, 'Grids' => '' ); diff --git a/application/views/search/search_result_ajax.php b/application/views/search/search_result_ajax.php index 639fe95ea..18cce9d8b 100644 --- a/application/views/search/search_result_ajax.php +++ b/application/views/search/search_result_ajax.php @@ -192,7 +192,7 @@ $ci =& get_instance(); case 'SOTA': echo '' . ($row->COL_SOTA_REF); break; case 'WWFF': echo '' . ($row->COL_WWFF_REF); break; case 'POTA': echo '' . ($row->COL_POTA_REF); break; - case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE)==0?$row->COL_VUCC_GRIDS:$row->COL_GRIDSQUARE; break; + case 'Grid': echo ''; echo strlen($row->COL_GRIDSQUARE ?? '')==0?$row->COL_VUCC_GRIDS ?? '':$row->COL_GRIDSQUARE; break; case 'Distance':echo '' . ($row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : ''); break; case 'Band': echo ''; if($row->COL_SAT_NAME != null) { echo $row->COL_SAT_NAME; } else { echo strtolower($row->COL_BAND); }; break; case 'State': echo '' . ($row->COL_STATE); break;