From 811639df1d1877c95e72e4333ab9ef362da86416 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 28 Jan 2025 19:24:53 +0100 Subject: [PATCH] Fixed js and info messages for upload --- application/controllers/Clublog.php | 7 +++---- application/models/Clublog_model.php | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/application/controllers/Clublog.php b/application/controllers/Clublog.php index 66ec511e4..603542e2c 100644 --- a/application/controllers/Clublog.php +++ b/application/controllers/Clublog.php @@ -130,9 +130,6 @@ class Clublog extends CI_Controller $users = $this->clublog_model->get_clublog_users($this->session->userdata('user_id')); if (!empty($users)) { - $stationinfo = $this->clublog_model->stations_with_clublog_enabled(); - $info = $stationinfo->result(); - $data['info'] = $info; foreach ($users as $user) { $data['status'] = 'OK'; $data['infomessage'] = $this->clublog_model->uploadUser($user->user_id, $user->user_clublog_name, $user->user_clublog_password, $clean_station_id); @@ -141,8 +138,10 @@ class Clublog extends CI_Controller } else { $data['status'] = 'Error'; $data['errormessages'] = __("No user has configured Clublog."); - $data['info'] = ''; } + $stationinfo = $this->clublog_model->stations_with_clublog_enabled(); + $info = $stationinfo->result(); + $data['info'] = $info; header('Content-type: application/json'); echo json_encode($data); diff --git a/application/models/Clublog_model.php b/application/models/Clublog_model.php index 6db681722..54cdcee49 100644 --- a/application/models/Clublog_model.php +++ b/application/models/Clublog_model.php @@ -93,25 +93,27 @@ class Clublog_model extends CI_Model // If Clublog Accepts mark the QSOs if (preg_match('/\baccepted\b/', $response)) { - $return = "QSOs uploaded and Logbook QSOs marked as sent to Clublog"; + $return = "QSOs uploaded and Logbook QSOs marked as sent to Clublog."; $this->mark_qsos_sent($station_row->station_id); - $return = "Clublog upload for " . $station_row->station_callsign; + $return .= " Clublog upload for " . $station_row->station_callsign . ' successfully sent.'; log_message('info', 'Clublog upload for ' . $station_row->station_callsign . ' successfully sent.'); } else if (preg_match('/checksum duplicate/', $response)) { - $return = "QSOs uploaded (asduplicate!) and Logbook QSOs marked as sent to Clublog"; + $return = "QSOs uploaded (as duplicate!) and Logbook QSOs marked as sent to Clublog"; $this->mark_qsos_sent($station_row->station_id); - $return = "Clublog upload for " . $station_row->station_callsign; + $return .= " Clublog upload for " . $station_row->station_callsign . ' successfully sent.'; log_message('info', 'Clublog DUPLICATE upload for ' . $station_row->station_callsign . ' successfully sent.'); } else { - $return = "Error " . $response; + $return = 'Clublog upload for ' . $station_row->station_callsign . ' failed reason ' . $response; log_message('error', 'Clublog upload for ' . $station_row->station_callsign . ' failed reason ' . $response); if (substr($response,0,13) == 'Upload denied') { // Deactivate Upload for Station if Clublog rejects it due to non-configured Call (prevent being blacklisted at Clublog) - $sql = 'update station_profile set clublogignore = 1 where station_id = ?'; - $this->db->query($sql,$station_row->station_id); + log_message('info', 'Deactivated upload for station ' . $station_row->station_callsign . ' due to non-configured Call (prevent being blacklisted at Clublog.'); + $sql = 'update station_profile set clublogignore = 1 where station_id = ?'; + $this->db->query($sql,$station_row->station_id); } if (substr($response,0,14) == 'Login rejected') { // Deactivate Upload for Station if Clublog rejects it due to wrong credentials (prevent being blacklisted at Clublog) - $sql = 'update station_profile set clublogignore = 1 where station_id = ?'; - $this->db->query($sql,$station_row->station_id); + log_message('info', 'Deactivated upload for station ' . $station_row->station_callsign . ' due to wrong credentials (prevent being blacklisted at Clublog.'); + $sql = 'update station_profile set clublogignore = 1 where station_id = ?'; + $this->db->query($sql,$station_row->station_id); } }