diff --git a/application/controllers/Stationsetup.php b/application/controllers/Stationsetup.php index 44f1e9b69..f874b800e 100644 --- a/application/controllers/Stationsetup.php +++ b/application/controllers/Stationsetup.php @@ -366,5 +366,20 @@ class Stationsetup extends CI_Controller { echo json_encode($data); } + public function togglePublicSearch() { + $id = xss_clean($this->input->post('id',true)); + $publicSearch = xss_clean($this->input->post('checked',true)); + if ($id ?? '' != '') { + $this->load->model('stationsetup_model'); + $this->stationsetup_model->togglePublicSearch($id, $publicSearch); + $data['success']=1; + } else { + $data['success']=0; + $data['flashdata']='Not allowed'; + } + echo json_encode($data); + + } + } diff --git a/application/models/Stationsetup_model.php b/application/models/Stationsetup_model.php index f728be95f..b9a42dec5 100644 --- a/application/models/Stationsetup_model.php +++ b/application/models/Stationsetup_model.php @@ -34,6 +34,16 @@ class Stationsetup_model extends CI_Model { $this->db->where('logbook_id', xss_clean($this->input->post('id', true))); $this->db->update('station_logbooks'); } + + function togglePublicSearch($id, $publicSearch) { + $data = array( + 'public_search' => ($publicSearch === 'true' ? 1 : 0) + ); + + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('logbook_id', $id); + $this->db->update('station_logbooks', $data); + } } ?> diff --git a/application/views/stationsetup/stationsetup.php b/application/views/stationsetup/stationsetup.php index cbce7306d..37a108382 100644 --- a/application/views/stationsetup/stationsetup.php +++ b/application/views/stationsetup/stationsetup.php @@ -70,10 +70,10 @@