diff --git a/application/controllers/Oqrs.php b/application/controllers/Oqrs.php index fde96ff9f..f57606136 100644 --- a/application/controllers/Oqrs.php +++ b/application/controllers/Oqrs.php @@ -89,8 +89,14 @@ class Oqrs extends CI_Controller { public function get_qsos_grouped() { $this->load->model('oqrs_model'); - $data['result'] = $this->oqrs_model->getQueryDataGrouped($this->input->post('callsign', TRUE)); + $this->load->model('publicsearch'); + + $slug = $this->input->post('slug', TRUE); + $userid = $this->publicsearch->get_userid_for_slug($slug); + + $data['result'] = $this->oqrs_model->getQueryDataGrouped($this->input->post('callsign', TRUE), $userid); $data['callsign'] = $this->input->post('callsign', TRUE); + $data['userid'] = $this->input->post('userid', TRUE); if($this->input->post('widget') != 'true') { $this->load->view('oqrs/request_grouped', $data); diff --git a/application/controllers/Widgets.php b/application/controllers/Widgets.php index ece998982..ca07ec2e4 100644 --- a/application/controllers/Widgets.php +++ b/application/controllers/Widgets.php @@ -48,7 +48,7 @@ class Widgets extends CI_Controller { // date format $data['date_format'] = $this->config->item('qso_date_format'); // date format from /config/wavelog.php - + $this->load->model('logbook_model'); $this->load->model('logbooks_model'); $this->load->model('stationsetup_model'); @@ -72,7 +72,7 @@ class Widgets extends CI_Controller { $user_id = $this->stationsetup_model->public_slug_exists_userid($logbook_slug); $widget_options = $this->get_qso_widget_options($user_id); - $data['show_time'] = $widget_options->display_qso_time; + $data['show_time'] = $widget_options->display_qso_time; $data['last_qsos_list'] = $this->logbook_model->get_last_qsos($qso_count, $logbooks_locations_array); $this->load->view('widgets/qsos', $data); @@ -88,9 +88,9 @@ class Widgets extends CI_Controller { return; } - $slug = $this->input->get('slug', TRUE); - if ($slug != null) { - $data['logo_url'] = base_url() . 'index.php/visitor/' . $slug; + $data['slug'] = $this->input->get('slug', TRUE); + if ($data['slug'] != null) { + $data['logo_url'] = base_url() . 'index.php/visitor/' . $data['slug']; } else { $data['logo_url'] = 'https://github.com/wavelog/wavelog'; } diff --git a/application/models/Oqrs_model.php b/application/models/Oqrs_model.php index c65b2e0e9..ddd87e1fe 100644 --- a/application/models/Oqrs_model.php +++ b/application/models/Oqrs_model.php @@ -10,7 +10,7 @@ class Oqrs_model extends CI_Model { function get_station_info($station_id) { $binding = []; - $sql = 'select + $sql = 'select count(*) as count, min(col_time_on) as mindate, max(col_time_on) as maxdate @@ -67,17 +67,19 @@ class Oqrs_model extends CI_Model { /* * Builds query depending on what we are searching for */ - function getQueryDataGrouped($callsign) { + function getQueryDataGrouped($callsign, $userid) { $binding = []; - $sql = 'select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, col_band, station_callsign, station_profile_name, l.station_id from ' . $this->config->item('table_name') . ' as l join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and l.col_call = ? and l.col_prop_mode != "SAT"'; + $sql = 'select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, col_band, station_callsign, station_profile_name, l.station_id from ' . $this->config->item('table_name') . ' as l join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and l.col_call = ? and l.col_prop_mode != "SAT" and station_profile.user_id = ?'; $binding[] = $callsign; + $binding[] = $userid; - $sql .= ' union all select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, "SAT" col_band, station_callsign, station_profile_name, l.station_id from ' . - $this->config->item('table_name') . ' l' . - ' join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and col_call = ? and col_prop_mode = "SAT"'; + $sql .= ' union all select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, "SAT" col_band, station_callsign, station_profile_name, l.station_id from ' . + $this->config->item('table_name') . ' l' . + ' join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and col_call = ? and col_prop_mode = "SAT" and station_profile.user_id = ?'; $binding[] = $callsign; + $binding[] = $userid; $query = $this->db->query($sql, $binding); @@ -145,7 +147,7 @@ class Oqrs_model extends CI_Model { $data['status'] = '2'; } $data['qsoid'] = $qsoid; - + $this->db->insert('oqrs', $data); if(!in_array($postdata['station_id'], $station_ids)){ array_push($station_ids, $postdata['station_id']); @@ -178,9 +180,9 @@ class Oqrs_model extends CI_Model { $data['status'] = '2'; } $data['qsoid'] = $qsoid; - + $this->db->insert('oqrs', $data); - + if(!in_array($qso[4], $station_ids)){ array_push($station_ids, $qso[4]); } @@ -228,7 +230,7 @@ class Oqrs_model extends CI_Model { $binding = []; - $sql = 'select * from ' . $this->config->item('table_name') . + $sql = 'select * from ' . $this->config->item('table_name') . ' where (col_band = ? or col_prop_mode = ?) and col_call = ? and date(col_time_on) = ? @@ -236,7 +238,7 @@ class Oqrs_model extends CI_Model { or col_submode = ?) and timediff(time(col_time_on), ?) <= 3000 and station_id = ?'; - + $binding[] = $qsodata['band']; $binding[] = $qsodata['band']; $binding[] = $qsodata['requestcallsign']; @@ -245,7 +247,7 @@ class Oqrs_model extends CI_Model { $binding[] = $qsodata['mode']; $binding[] = $qsodata['time']; $binding[] = $qsodata['station_id']; - + $query = $this->db->query($sql, $binding); if ($result = $query->result()) { @@ -310,9 +312,9 @@ class Oqrs_model extends CI_Model { $data = array( 'status' => '2', ); - + $this->db->where('id', $id); - + $this->db->update('oqrs', $data); } @@ -325,7 +327,7 @@ class Oqrs_model extends CI_Model { if ($query->num_rows() > 0) { - $row = $query->row(); + $row = $query->row(); return $row->oqrs_text; } @@ -341,7 +343,7 @@ class Oqrs_model extends CI_Model { if ($query->num_rows() > 0) { - $row = $query->row(); + $row = $query->row(); return $row->oqrs_email; } diff --git a/application/views/widgets/oqrs.php b/application/views/widgets/oqrs.php index c4f3e98d6..a5ec8ce70 100644 --- a/application/views/widgets/oqrs.php +++ b/application/views/widgets/oqrs.php @@ -1,6 +1,6 @@ -