From 90340a5188692edf0b08ef901302925539191b64 Mon Sep 17 00:00:00 2001 From: Thomas Werzmirzowsky Date: Sun, 9 Jan 2022 12:09:35 +0100 Subject: [PATCH 1/2] added logbook filter to simple and advanced search --- application/controllers/Logbook.php | 21 +++++++++++++-------- application/controllers/Search.php | 6 ++++++ application/models/Search.php | 5 +++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 4936d31e..4d9f0aca 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -190,8 +190,8 @@ class Logbook extends CI_Controller { return false; $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if(!empty($logbooks_locations_array)) { if($type == "SAT") { @@ -311,8 +311,8 @@ class Logbook extends CI_Controller { ]; $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if(!empty($logbooks_locations_array)) { if($type == "SAT") { @@ -567,15 +567,20 @@ class Logbook extends CI_Controller { if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } - //$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - $this->db->from($this->config->item('table_name')); - - $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + //$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); + $this->db->from($this->config->item('table_name')); + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + $this->db->group_start(); $this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id); $this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id); $this->db->or_like(''.$this->config->item('table_name').'.COL_VUCC_GRIDS', $id); + $this->db->group_end(); + $this->db->where_in(''.$this->config->item('table_name').'.station_id', $logbooks_locations_array); $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc'); $query = $this->db->get(); diff --git a/application/controllers/Search.php b/application/controllers/Search.php index 7f11437b..ae6baa61 100644 --- a/application/controllers/Search.php +++ b/application/controllers/Search.php @@ -262,10 +262,16 @@ class Search extends CI_Controller { } function fetchQueryResult($json, $returnquery) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); $search_items = json_decode($json, true); + $this->db->group_start(); $this->buildWhere($search_items); + $this->db->group_end(); + $this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array); $this->db->order_by('COL_TIME_ON', 'DESC'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); diff --git a/application/models/Search.php b/application/models/Search.php index a3becd21..3621bec3 100644 --- a/application/models/Search.php +++ b/application/models/Search.php @@ -3,7 +3,12 @@ class Search extends CI_Model { function callsign_iota($reference) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->db->where('COL_IOTA', $reference); + $this->db->where_in('station_id', $logbooks_locations_array); $query = $this->db->get($this->config->item('table_name')); return $query; From b9291094288b2fb962c097d99c439dc9de5ddaea Mon Sep 17 00:00:00 2001 From: Thomas Werzmirzowsky Date: Sun, 6 Feb 2022 09:41:11 +0100 Subject: [PATCH 2/2] changed search filter from active logbook to all stations of the user also changed get_qso($id) accordingly (otherwise no details of the QSOs from other logbooks can be shown) --- application/controllers/Logbook.php | 6 +----- application/controllers/Search.php | 6 +----- application/models/Logbook_model.php | 6 +----- application/models/Search.php | 7 ++----- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 280ed5b1..a433cf0f 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -568,10 +568,6 @@ class Logbook extends CI_Controller { if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; } - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - //$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); $this->db->from($this->config->item('table_name')); @@ -581,7 +577,7 @@ class Logbook extends CI_Controller { $this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id); $this->db->or_like(''.$this->config->item('table_name').'.COL_VUCC_GRIDS', $id); $this->db->group_end(); - $this->db->where_in(''.$this->config->item('table_name').'.station_id', $logbooks_locations_array); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); $this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', 'desc'); $query = $this->db->get(); diff --git a/application/controllers/Search.php b/application/controllers/Search.php index 5d1a2b9b..41164c7a 100644 --- a/application/controllers/Search.php +++ b/application/controllers/Search.php @@ -262,19 +262,15 @@ class Search extends CI_Controller { } function fetchQueryResult($json, $returnquery) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - $search_items = json_decode($json, true); $this->db->group_start(); $this->buildWhere($search_items); $this->db->group_end(); - $this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array); $this->db->order_by('COL_TIME_ON', 'DESC'); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); if ($returnquery) { $query = $this->db->get_compiled_select($this->config->item('table_name')); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index b6a5a454..f38237f7 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -935,15 +935,11 @@ class Logbook_model extends CI_Model { } function get_qso($id) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - $this->db->select(''.$this->config->item('table_name').'.*, station_profile.*'); $this->db->from($this->config->item('table_name')); $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); - $this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); $this->db->where('COL_PRIMARY_KEY', $id); return $this->db->get(); diff --git a/application/models/Search.php b/application/models/Search.php index 3621bec3..152dc58e 100644 --- a/application/models/Search.php +++ b/application/models/Search.php @@ -3,12 +3,9 @@ class Search extends CI_Model { function callsign_iota($reference) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - $this->db->where('COL_IOTA', $reference); - $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); $query = $this->db->get($this->config->item('table_name')); return $query;