wavelog/application/models/Logbooks_model.php

331 lines
8.7 KiB
PHP
Raw Normal View History

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Logbooks_model extends CI_Model {
2024-01-29 14:38:15 +00:00
function show_all() {
$this->db->where('user_id', $this->session->userdata('user_id'));
return $this->db->get('station_logbooks');
}
function CountAllStationLogbooks() {
// count all logbooks
$this->db->where('user_id =', NULL);
2022-10-11 16:54:32 +01:00
$query = $this->db->get('station_logbooks');
return $query->num_rows();
}
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
function add($logbook_name = '') {
// Create data array with field values
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
if ($logbook_name ?? '' != '') {
$data = array(
'user_id' => $this->session->userdata('user_id'),
'logbook_name' => $logbook_name,
);
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
// Insert Records
$this->db->insert('station_logbooks', $data);
$logbook_id = $this->db->insert_id();
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
// check if user has no active logbook yet
if ($this->session->userdata('active_station_logbook') === null) {
// set logbook active
$this->set_logbook_active($logbook_id);
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
// update user session data
$this->load->model('user_model');
$this->user_model->update_session($this->session->userdata('user_id'));
}
return $logbook_id;
} else {
return -1;
}
}
function CreateDefaultLogbook() {
// Get the first USER ID from user table in the database
$id = $this->db->get("users")->row()->user_id;
2024-01-29 14:38:15 +00:00
$data = array(
'user_id' => $id,
'logbook_name' => "Default Logbook",
);
2024-01-29 14:38:15 +00:00
$this->db->insert('station_logbooks', $data);
$logbook_id = $this->db->insert_id();
$this->set_logbook_active($logbook_id, $id);
}
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
function delete($clean_id) {
// Clean ID
// do not delete active logbook
if ($this->session->userdata('active_station_logbook') === $clean_id) {
return;
}
// Also clean up static map images first
if (!$this->load->is_loaded('staticmap_model')) {
$this->load->model('staticmap_model');
}
$this->staticmap_model->remove_static_map_image(null, $clean_id);
// Delete logbook
$this->db->where('user_id', $this->session->userdata('user_id'));
Station setup (#175) * The start of station setup * Added modals new logbook and new location * Added 1st JSON-Create Logbook (PHP) * Added 1st JSON-Create Logbook (JS) * Changed to small buttons * A bit more errorhandling (JS) * Moved collecting of params to controller and added errorhandling * Added Delete-Function (with confirmation) * Moved view to new folder and added delete Logbook * Added AJAX for setActive Book * Added AJAX for setActiveBook (JS) * Partially working reload logbook table * Dynamic loading of logbooks (PHP) * Dynamic loading of logbooks (JS) * Reload location table * Removed duplicate return statement * Fixed Zoo of params to JSON-Out * Fixed RenderBug (not yet finished) at JS * Fixed DT error * Fixed CSS * Changed setActiveStation from link to Ajax (PHP) * Changed setActiveStation from link to Ajax (JS) * Added confirmation to changeActiveStation * Changed EmptyStation to AJAX (PHP) * Changed EmptyStation to AJAX (JS) * Changed DeleteStation to AJAX (JS) * Changed DeleteStation to AJAX (PHP) * Tidy up code a little * Re-added favorites * Ajaxyfing favorite location * Fixed clicking on favorite * Fixed favorite star * Tweaked new logbook dialog * Fixed public search badge * Fix badges on first load * Reloads stations on load * Redirect to station setup * Re-added translation * Fixed more badges * Added menu item translation * Header with translated menu * Updated warning links on dashboard to go to station setup * Added missing lang lines for Polish and Czech * Changed links in Quickswitch to station setup * station setup in quickswitcher * Make station location ID a separate (and sortable) column * Added missing ID * Relocated eQSL-Thing to station_model to reduce redundancies * Removed Debug-Stuff * Moved get_options to get_default_eqsl_message within QSO-Controller * Moved generic get_options to more specific get_eqsl_default_message * Removed loading of options_model, since it is already loaded via "autload"... * dynamic quickswitcher * disabled button for active location * typo * removed empty unused function * comment * reload stationsetup list if we are on this page * don't grey out the locations * dynamic loading in both directions * rename function to make it more clear * readability --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: HB9HIL <fabian.berg@hb9hil.org> Co-authored-by: phl0 <github@florian-wolters.de>
2024-03-03 21:52:51 +01:00
$this->db->where('logbook_id', $clean_id);
$this->db->delete('station_logbooks');
}
function edit() {
$data = array(
'logbook_name' => xss_clean($this->input->post('station_logbook_name', true)),
);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', xss_clean($this->input->post('logbook_id', true)));
$this->db->update('station_logbooks', $data);
}
function set_logbook_active($id, $user_id = null) {
// Clean input
$cleanId = xss_clean($id);
// check if user_id is set
if ($user_id === null) {
$user_id = $this->session->userdata('user_id');
} else {
$user_id = xss_clean($user_id);
}
// be sure that logbook belongs to user
2021-10-31 10:17:14 +01:00
if (!$this->check_logbook_is_accessible($cleanId)) {
return;
}
$data = array(
'active_station_logbook' => $cleanId,
);
$this->db->where('user_id', $user_id);
$this->db->update('users', $data);
}
function logbook($id) {
// Clean ID
$clean_id = $this->security->xss_clean($id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', $clean_id);
return $this->db->get('station_logbooks');
}
function find_name($id) {
// Clean ID
$clean_id = $this->security->xss_clean($id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', $clean_id);
$query = $this->db->get('station_logbooks');
if ($query->num_rows() > 0){
2024-01-29 14:38:15 +00:00
foreach ($query->result() as $row) {
return $row->logbook_name;
}
2024-01-29 14:38:15 +00:00
} else {
return "n/a";
}
}
// Creates relationship between a logbook and a station location
function create_logbook_location_link($logbook_id, $location_id) {
// Clean ID
$clean_logbook_id = $this->security->xss_clean($logbook_id);
$clean_location_id = $this->security->xss_clean($location_id);
// be sure that logbook belongs to user
2021-10-31 10:17:14 +01:00
if (!$this->check_logbook_is_accessible($clean_logbook_id)) {
return;
}
// be sure that station belongs to user
2024-01-29 14:38:15 +00:00
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($clean_location_id)) {
return;
}
// Create data array with field values
$data = array(
'station_logbook_id' => $clean_logbook_id,
'station_location_id' => $clean_location_id,
);
// Insert Record
$this->db->insert('station_logbooks_relationship', $data);
}
2024-01-29 14:38:15 +00:00
function public_slug_exists($slug) {
$this->db->where('public_slug', $this->security->xss_clean($slug));
$query = $this->db->get('station_logbooks');
if ($query->num_rows() > 0){
return true;
2024-01-29 14:38:15 +00:00
} else {
return false;
}
}
function public_slug_exists_logbook_id($slug) {
$this->db->where('public_slug', $this->security->xss_clean($slug));
$query = $this->db->get('station_logbooks');
if ($query->num_rows() > 0){
2024-01-29 14:38:15 +00:00
foreach ($query->result() as $row) {
return $row->logbook_id;
}
2024-01-29 14:38:15 +00:00
} else {
return false;
}
}
function is_public_slug_available($slug) {
// Clean public_slug
$clean_slug = $this->security->xss_clean($slug);
$this->db->where('public_slug', $clean_slug);
$query = $this->db->get('station_logbooks');
if ($query->num_rows() > 0){
return false;
2024-01-29 14:38:15 +00:00
} else {
return true;
}
}
2023-07-10 17:11:40 +02:00
function save_public_search($public_search, $logbook_id) {
$data = array(
'public_search' => xss_clean($public_search),
);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', xss_clean($logbook_id));
$this->db->update('station_logbooks', $data);
}
function save_public_slug($public_slug, $logbook_id) {
$data = array(
'public_slug' => xss_clean($public_slug),
);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', xss_clean($logbook_id));
2022-10-15 20:50:20 +02:00
$this->db->update('station_logbooks', $data);
}
function remove_public_slug($logbook_id) {
$this->db->set('public_slug', null);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', xss_clean($logbook_id));
$this->db->update('station_logbooks');
}
function list_logbook_relationships($logbook_id) {
$relationships_array = array();
$this->db->where('station_logbook_id', $logbook_id);
$query = $this->db->get('station_logbooks_relationship');
2024-01-29 14:38:15 +00:00
if ($query->num_rows() > 0){
2024-01-29 14:38:15 +00:00
foreach ($query->result() as $row) {
array_push($relationships_array, $row->station_location_id);
}
return $relationships_array;
2024-01-29 14:38:15 +00:00
} else {
return array(-1); // Put some default-Value here, if no relation found
}
}
function list_logbooks_linked($logbook_id) {
$relationships_array = array();
$this->db->where('station_logbook_id', $logbook_id);
$query = $this->db->get('station_logbooks_relationship');
2024-01-29 14:38:15 +00:00
if ($query->num_rows() > 0){
2024-01-29 14:38:15 +00:00
foreach ($query->result() as $row) {
array_push($relationships_array, $row->station_location_id);
}
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as end');
$this->db->where_in('station_id', $relationships_array);
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
$query = $this->db->get('station_profile');
2024-01-29 14:38:15 +00:00
return $query;
2024-01-29 14:38:15 +00:00
} else {
return false;
}
}
function delete_relationship($logbook_id, $station_id) {
// Clean ID
$clean_logbook_id = $this->security->xss_clean($logbook_id);
$clean_station_id = $this->security->xss_clean($station_id);
// be sure that logbook belongs to user
2021-10-31 10:17:14 +01:00
if (!$this->check_logbook_is_accessible($clean_logbook_id)) {
return;
}
// be sure that station belongs to user
2024-01-29 14:38:15 +00:00
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($clean_station_id)) {
return;
}
2021-10-31 10:17:14 +01:00
// Delete relationship
$this->db->where('station_logbook_id', $clean_logbook_id);
$this->db->where('station_location_id', $clean_station_id);
$this->db->delete('station_logbooks_relationship');
}
2021-10-31 10:17:14 +01:00
public function check_logbook_is_accessible($id) {
2024-01-29 14:38:15 +00:00
// check if logbook belongs to user
$this->db->select('logbook_id');
2021-10-31 10:17:14 +01:00
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('logbook_id', $id);
$query = $this->db->get('station_logbooks');
if ($query->num_rows() == 1) {
return true;
}
return false;
}
public function find_active_station_logbook_from_userid($userid) {
$this->db->select('active_station_logbook');
$this->db->where('user_id', $userid);
$query = $this->db->get('users');
if ($query->num_rows() > 0){
2024-01-29 14:38:15 +00:00
foreach ($query->result() as $row) {
return $row->active_station_logbook;
}
} else {
return 0;
}
}
2023-07-10 17:11:40 +02:00
function public_search_enabled($logbook_id) {
$this->db->select('public_search');
$this->db->where('logbook_id', $logbook_id);
$query = $this->db->get('station_logbooks');
2024-01-29 14:38:15 +00:00
return $query->result_array()[0]['public_search'];
2023-07-10 17:11:40 +02:00
}
}
?>