mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
[Visitor] Only search activated searches
This commit is contained in:
@@ -5,36 +5,38 @@ class Publicsearch extends CI_Model {
|
||||
function search($slug, $callsign) {
|
||||
if ($this->public_search_enabled($slug)) {
|
||||
$userid = $this->get_userid_for_slug($slug);
|
||||
$this->db->like('COL_CALL', $callsign);
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
|
||||
$this->db->where('station_profile.user_id', $userid);
|
||||
$this->db->order_by('COL_TIME_ON', 'DESC');
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
$sql = "SELECT * FROM ".$this->config->item('table_name')."
|
||||
JOIN station_profile ON station_profile.station_id = ".$this->config->item('table_name').".station_id
|
||||
JOIN station_logbooks_relationship ON station_logbooks_relationship.station_location_id = station_profile.station_id
|
||||
JOIN station_logbooks ON station_logbooks.logbook_id = station_logbooks_relationship.station_logbook_id
|
||||
LEFT OUTER JOIN lotw_users ON lotw_users.callsign = ".$this->config->item('table_name').".col_call
|
||||
WHERE station_logbooks.public_search = 1
|
||||
AND station_profile.user_id = ?
|
||||
AND station_logbooks.public_slug = ?
|
||||
AND ".$this->config->item('table_name').".COL_CALL LIKE ?";
|
||||
$query = $this->db->query($sql, array($userid, $slug, $callsign));
|
||||
return $query;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_userid_for_slug($slug) {
|
||||
$this->db->select('user_id');
|
||||
$this->db->where('public_slug', $slug);
|
||||
$query = $this->db->get('station_logbooks');
|
||||
$sql = "SELECT user_id FROM station_logbooks WHERE public_slug = ?";
|
||||
$query = $this->db->query($sql, array($slug));
|
||||
return $query->result_array()[0]['user_id'];
|
||||
}
|
||||
|
||||
function public_search_enabled($slug) {
|
||||
if ($slug) {
|
||||
$this->db->select('public_search');
|
||||
$this->db->where('public_slug', $slug);
|
||||
$query = $this->db->get('station_logbooks');
|
||||
$sql = "SELECT public_search FROM station_logbooks WHERE public_slug = ?";
|
||||
$query = $this->db->query($sql, array($slug));
|
||||
|
||||
if ($query->result_array()[0]['public_search'] == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user