mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-27 01:24:16 +00:00
Make controllers assign variables and remove CI calls from views
This commit is contained in:
@@ -17,8 +17,13 @@ class Oqrs extends CI_Controller {
|
||||
|
||||
public function index($public_slug = NULL) {
|
||||
$this->load->model('oqrs_model');
|
||||
$this->load->model('publicsearch');
|
||||
|
||||
$data['slug'] = $this->security->xss_clean($public_slug);
|
||||
$slug = $this->security->xss_clean($public_slug);
|
||||
$data['slug'] = $slug;
|
||||
$data['oqrs_enabled'] = $this->oqrs_model->oqrs_enabled($slug);
|
||||
$data['public_search_enabled'] = $this->publicsearch->public_search_enabled($slug);
|
||||
$data['disable_oqrs'] = $this->config->item('disable_oqrs');
|
||||
$data['stations'] = $this->oqrs_model->get_oqrs_stations();
|
||||
$data['page_title'] = __("Log Search & OQRS");
|
||||
$data['global_oqrs_text'] = $this->optionslib->get_option('global_oqrs_text');
|
||||
@@ -26,7 +31,7 @@ class Oqrs extends CI_Controller {
|
||||
|
||||
$this->load->view('visitor/layout/header', $data);
|
||||
$this->load->view('oqrs/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
$this->load->view('interface_assets/footer', $data);
|
||||
}
|
||||
|
||||
public function get_station_info() {
|
||||
@@ -236,4 +241,5 @@ class Oqrs extends CI_Controller {
|
||||
header("Content-Type: application/json");
|
||||
print json_encode($qsos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ class Visitor extends CI_Controller {
|
||||
$this->load->model('cat');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('logbooks_model');
|
||||
$this->load->model('oqrs_model');
|
||||
$this->load->model('publicsearch');
|
||||
|
||||
if($this->logbooks_model->public_slug_exists($public_slug)) {
|
||||
|
||||
@@ -132,6 +134,10 @@ class Visitor extends CI_Controller {
|
||||
$data['page_title'] = __("Dashboard");
|
||||
$data['slug'] = $public_slug;
|
||||
|
||||
$data['oqrs_enabled'] = $this->oqrs_model->oqrs_enabled($public_slug);
|
||||
$data['public_search_enabled'] = $this->publicsearch->public_search_enabled($public_slug);
|
||||
$data['disable_oqrs'] = $this->config->item('disable_oqrs');
|
||||
|
||||
$this->load->view('visitor/layout/header', $data);
|
||||
$this->load->view('visitor/index');
|
||||
$this->load->view('visitor/layout/footer');
|
||||
@@ -180,8 +186,13 @@ class Visitor extends CI_Controller {
|
||||
public function satellites()
|
||||
{
|
||||
|
||||
$this->load->model('publicsearch');
|
||||
$this->load->model('oqrs_model');
|
||||
$slug = $this->security->xss_clean($this->uri->segment(3));
|
||||
$data['slug'] = $slug;
|
||||
$data['public_search_enabled'] = $this->publicsearch->public_search_enabled($slug);
|
||||
$data['oqrs_enabled'] = $this->oqrs_model->oqrs_enabled($slug);
|
||||
$data['disable_oqrs'] = $this->config->item('disable_oqrs');
|
||||
$this->load->model('logbooks_model');
|
||||
if($this->logbooks_model->public_slug_exists($slug)) {
|
||||
// Load the public view
|
||||
@@ -383,31 +394,14 @@ class Visitor extends CI_Controller {
|
||||
$this->load->view('visitor/layout/footer');
|
||||
}
|
||||
|
||||
public function oqrs_enabled($slug) {
|
||||
$this->load->model('oqrs_model');
|
||||
$this->load->model('Logbooks_model');
|
||||
$logbook_id = $this->Logbooks_model->public_slug_exists_logbook_id($slug);
|
||||
if (!empty($this->oqrs_model->getOqrsStationsFromSlug($logbook_id))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function public_search_enabled($slug) {
|
||||
$this->load->model('Logbooks_model');
|
||||
$logbook_id = $this->Logbooks_model->public_slug_exists_logbook_id($slug);
|
||||
if ($this->Logbooks_model->public_search_enabled($logbook_id) == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function search() {
|
||||
$this->load->model('publicsearch');
|
||||
$this->load->model('oqrs_model');
|
||||
$callsign = trim($this->security->xss_clean($this->input->post('callsign')));
|
||||
$public_slug = $this->security->xss_clean($this->input->post('public_slug'));
|
||||
$this->load->model('publicsearch');
|
||||
$data['public_search_enabled'] = $this->publicsearch->public_search_enabled($public_slug);
|
||||
$data['oqrs_enabled'] = $this->oqrs_model->oqrs_enabled($public_slug);
|
||||
$data['disable_oqrs'] = $this->config->item('disable_oqrs');
|
||||
$data['page_title'] = __("Public Search");
|
||||
$data['callsign'] = $callsign;
|
||||
$data['slug'] = $public_slug;
|
||||
@@ -570,4 +564,4 @@ class Visitor extends CI_Controller {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,4 +386,19 @@ class Oqrs_model extends CI_Model {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function oqrs_enabled($slug) {
|
||||
if ($slug) {
|
||||
$this->load->model('Logbooks_model');
|
||||
$logbook_id = $this->Logbooks_model->public_slug_exists_logbook_id($slug);
|
||||
if (!empty($this->getOqrsStationsFromSlug($logbook_id))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,13 +24,17 @@ class Publicsearch extends CI_Model {
|
||||
}
|
||||
|
||||
function public_search_enabled($slug) {
|
||||
$this->db->select('public_search');
|
||||
$this->db->where('public_slug', $slug);
|
||||
$query = $this->db->get('station_logbooks');
|
||||
if ($query->result_array()[0]['public_search'] == 1) {
|
||||
return true;
|
||||
if ($slug) {
|
||||
$this->db->select('public_search');
|
||||
$this->db->where('public_slug', $slug);
|
||||
$query = $this->db->get('station_logbooks');
|
||||
if ($query->result_array()[0]['public_search'] == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ if ($lang_code != 'en' && !file_exists(FCPATH . "assets/json/datatables_language
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</script>
|
||||
<?php if ($this->CI->public_search_enabled($slug) || $this->session->userdata('user_type') >= 2) { ?>
|
||||
<?php if ($public_search_enabled || $this->session->userdata('user_type') >= 2) { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/datatables.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/dataTables.buttons.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/buttons.html5.min.js"></script>
|
||||
|
||||
@@ -68,8 +68,7 @@
|
||||
<a class="nav-link" href="<?php echo site_url('visitor/satellites/'.$slug);?>"><?= __("Gridsquares"); ?></a>
|
||||
</li>
|
||||
<?php }
|
||||
$this->CI =& get_instance();
|
||||
if ($this->CI->oqrs_enabled($slug) && !$this->CI->config->item('disable_oqrs')) {
|
||||
if ($oqrs_enabled && !$disable_oqrs) {
|
||||
?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?php echo site_url('oqrs/index/'.$slug);?>"><?= __("OQRS"); ?></a>
|
||||
@@ -91,8 +90,7 @@
|
||||
</ul>
|
||||
<div class="m-2">
|
||||
<?php if (!empty($slug)) {
|
||||
$this->CI =& get_instance();
|
||||
if ($this->CI->public_search_enabled($slug)) { ?>
|
||||
if ($public_search_enabled) { ?>
|
||||
<form method="post" name="searchForm" action="<?php echo site_url('visitor/search'); ?>" onsubmit="return validateForm()" class="d-flex align-items-center">
|
||||
<input class="form-control me-sm-2" id="searchcall" type="search" name="callsign" placeholder="<?= __("Search Callsign"); ?>" <?php if (isset($callsign) && $callsign != '') { echo 'value="'.strtoupper($callsign).'"'; } ?> aria-label="Search" data-toogle="tooltip" data-bs-placement="bottom" title="<?= __("Please enter a callsign!"); ?>">
|
||||
<input type="hidden" name="public_slug" value="<?php echo $slug; ?>">
|
||||
|
||||
Reference in New Issue
Block a user