From 71ffe7fc6b537b28bb1c07b54eab9bd288fb2771 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 28 Jan 2025 07:53:17 +0100 Subject: [PATCH] Added config switch to upload function in controller --- application/controllers/Clublog.php | 39 ++++++++++++++++------------- assets/js/sections/clublog.js | 18 +++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/application/controllers/Clublog.php b/application/controllers/Clublog.php index 089a7dc68..66ec511e4 100644 --- a/application/controllers/Clublog.php +++ b/application/controllers/Clublog.php @@ -122,28 +122,33 @@ class Clublog extends CI_Controller } public function uploadlog() { - $this->load->model('clublog_model'); + if (!($this->config->item('disable_manual_clublog'))) { + $this->load->model('clublog_model'); - $clean_station_id = $this->security->xss_clean($this->input->post('station_id')); + $clean_station_id = $this->security->xss_clean($this->input->post('station_id')); - $users = $this->clublog_model->get_clublog_users($this->session->userdata('user_id')); + $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); + 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); + $data['errormessages'] = ''; + } + } else { + $data['status'] = 'Error'; + $data['errormessages'] = __("No user has configured Clublog."); + $data['info'] = ''; } - } else { - $data['status'] = 'Error'; - $data['errormessages']= __("No user has configured Clublog."); - $data['info'] = ''; - } - header('Content-type: application/json'); - echo json_encode($data); + header('Content-type: application/json'); + echo json_encode($data); + } else { + redirect('dashboard'); + } } public function importlog() { diff --git a/assets/js/sections/clublog.js b/assets/js/sections/clublog.js index 0d50b9a6c..de371899e 100644 --- a/assets/js/sections/clublog.js +++ b/assets/js/sections/clublog.js @@ -26,6 +26,24 @@ function ExportClublog(station_id) { else { $(".card-body").append(''); } + + if (data.errormessages.length > 0) { + $("#clublog_export").append( + '
\n' + + '
\n' + + '
\n' + + ' Error Message\n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + '
\n' + + '
' + ); + $.each(data.errormessages, function (index, value) { + $(".errors").append('
  • ' + value); + }); + } } }); }