From 4f2afb98f59875b0e0728bcc9962cd666dd40f3d Mon Sep 17 00:00:00 2001 From: DB4SCW Date: Tue, 9 Sep 2025 09:59:15 +0000 Subject: [PATCH] change backend --- application/controllers/Hrdlog.php | 25 ++++++++++++++++++++++--- application/models/Logbook_model.php | 4 +++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php index 6e4fed20e..e5554cd9a 100644 --- a/application/controllers/Hrdlog.php +++ b/application/controllers/Hrdlog.php @@ -60,12 +60,31 @@ class Hrdlog extends CI_Controller { $postData = $this->input->post(); $this->load->model('logbook_model'); + + //checks for credentials. Returns "false" if credentials are there, but upload was disabled $result = $this->logbook_model->exists_hrdlog_credentials($postData['station_id']); + + //check for credential errors before accessing them + if($result == false){ + $data['status'] = 'Credential_Error'; + $data['infomessage'] = __("HRD Log upload for this station is disabled or credentials not filled in completely."); + $data['errormessages'] = array(__("HRD Log upload for this station is disabled or credentials not filled in completely.")); + echo json_encode($data); + return; + } + + //read hrd credentials $hrdlog_username = $result->hrdlog_username; $hrdlog_code = $result->hrdlog_code; - header('Content-type: application/json'); - $result = $this->Hrdlog_model->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code); - if ($result['status'] == 'OK') { + + //set header + header('Content-type: application/json'); + + //perform upload + $result = $this->Hrdlog_model->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code); + + //return success + if ($result['status'] == 'OK') { $stationinfo = $this->stations->stations_with_hrdlog_code(); $info = $stationinfo->result(); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index f3f1fc19e..2e8077edf 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -938,8 +938,10 @@ class Logbook_model extends CI_Model { * Function checks if a HRDLog Code and Username exists in the table with the given station id */ function exists_hrdlog_credentials($station_id) { + + //checks disabled state AND content of hrdlog_username and hrdlog_code $sql = 'select hrdlog_username, hrdlog_code, hrdlogrealtime from station_profile - where station_id = ? and hrdlogrealtime>=0'; + where station_id = ? and hrdlogrealtime >= 0 and COALESCE(hrdlog_username, "") != "" AND COALESCE(hrdlog_code, "") != "";'; $query = $this->db->query($sql, $station_id);