[QSO Entry] Cleanup and tighten up db lookup from QSO entry
这个提交包含在:
父节点
b427f78b2d
当前提交
1d0eaac66e
共有 2 个文件被更改,包括 126 次插入 和 141 次删除
|
|
@ -89,8 +89,15 @@ class Logbook extends CI_Controller {
|
|||
echo json_encode($return, JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
function json($callsign, $type, $band, $mode, $station_id = null)
|
||||
function json($tempcallsign, $temptype, $tempband, $tempmode, $tempstation_id = null)
|
||||
{
|
||||
// Cleaning for security purposes
|
||||
$callsign = $this->security->xss_clean($tempcallsign);
|
||||
$type = $this->security->xss_clean($temptype);
|
||||
$band = $this->security->xss_clean($tempband);
|
||||
$mode = $this->security->xss_clean($tempmode);
|
||||
$station_id = $this->security->xss_clean($tempstation_id);
|
||||
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
|
||||
|
||||
|
|
@ -120,6 +127,7 @@ class Logbook extends CI_Controller {
|
|||
"callsign_us_county" => "",
|
||||
"qsl_manager" => "",
|
||||
"bearing" => "",
|
||||
"latlng" => "",
|
||||
"workedBefore" => false,
|
||||
"lotw_member" => $lotw_member,
|
||||
"lotw_days" => $lotw_days,
|
||||
|
|
@ -131,25 +139,22 @@ class Logbook extends CI_Controller {
|
|||
|
||||
$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname'));
|
||||
|
||||
// Do we have local data for the Callsign?
|
||||
if($this->logbook_model->call_name($callsign) != null)
|
||||
{
|
||||
if ($this->session->userdata('user_measurement_base') == NULL) {
|
||||
$measurement_base = $this->config->item('measurement_base');
|
||||
} else {
|
||||
$measurement_base = $this->session->userdata('user_measurement_base');
|
||||
}
|
||||
|
||||
$return['callsign_name'] = $this->logbook_model->call_name($callsign);
|
||||
$return['callsign_qra'] = $this->logbook_model->call_qra($callsign);
|
||||
$return['callsign_distance'] = $this->distance($return['callsign_qra'], $station_id);
|
||||
$return['callsign_qth'] = $this->logbook_model->call_qth($callsign);
|
||||
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
|
||||
$return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign);
|
||||
$return['callsign_state'] = $this->logbook_model->call_state($callsign);
|
||||
$return['callsign_us_county'] = $this->logbook_model->call_us_county($callsign);
|
||||
$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id);
|
||||
$return['callsign_name'] = $this->nval($callbook['name'], $this->logbook_model->call_name($callsign));
|
||||
$return['callsign_qra'] = $this->nval($callbook['gridsquare'], $this->logbook_model->call_qra($callsign));
|
||||
$return['callsign_distance'] = $this->distance($return['callsign_qra']);
|
||||
$return['callsign_qth'] = $this->nval($callbook['city'], $this->logbook_model->call_qth($callsign));
|
||||
$return['callsign_iota'] = $this->nval($callbook['iota'], $this->logbook_model->call_iota($callsign));
|
||||
$return['qsl_manager'] = $this->nval($callbook['qslmgr'], $this->logbook_model->call_qslvia($callsign));
|
||||
$return['callsign_state'] = $this->nval($callbook['state'], $this->logbook_model->call_state($callsign));
|
||||
$return['callsign_us_county'] = $this->nval($callbook['us_county'], $this->logbook_model->call_us_county($callsign));
|
||||
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
|
||||
|
||||
if ($this->session->userdata('user_show_profile_image')) {
|
||||
if (isset($callbook)) {
|
||||
if ($callbook['image'] == "") {
|
||||
|
|
@ -164,51 +169,19 @@ class Logbook extends CI_Controller {
|
|||
|
||||
if ($return['callsign_qra'] != "") {
|
||||
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
|
||||
}
|
||||
|
||||
echo json_encode($return, JSON_PRETTY_PRINT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($callbook))
|
||||
{
|
||||
$return['callsign_name'] = $callbook['name'];
|
||||
$return['callsign_qra'] = $callbook['gridsquare'];
|
||||
$return['callsign_distance'] = $this->distance($callbook['gridsquare'], $station_id);
|
||||
$return['callsign_qth'] = $callbook['city'];
|
||||
$return['callsign_iota'] = $callbook['iota'];
|
||||
$return['callsign_state'] = $callbook['state'];
|
||||
$return['callsign_us_county'] = $callbook['us_county'];
|
||||
if ($this->session->userdata('user_show_profile_image')) {
|
||||
if ($callbook['image'] == "") {
|
||||
$return['image'] = "n/a";
|
||||
} else {
|
||||
$return['image'] = $callbook['image'];
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($callbook['qslmgr'])) {
|
||||
$return['qsl_manager'] = $callbook['qslmgr'];
|
||||
}
|
||||
if ($return['callsign_qra'] != "") {
|
||||
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
|
||||
}
|
||||
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $type, $band, $mode);
|
||||
}
|
||||
|
||||
if ($this->session->userdata('user_measurement_base') == NULL) {
|
||||
$measurement_base = $this->config->item('measurement_base');
|
||||
} else {
|
||||
$measurement_base = $this->session->userdata('user_measurement_base');
|
||||
}
|
||||
|
||||
$return['bearing'] = $this->bearing($return['callsign_qra'], $measurement_base, $station_id);
|
||||
}
|
||||
|
||||
echo json_encode($return, JSON_PRETTY_PRINT);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Returns $val2 first if it has value, even if it is null or empty string, if not return $val1.
|
||||
function nval($val1, $val2) {
|
||||
return (($val2 ?? "") === "" ? ($val1 ?? "") : ($val2 ?? ""));
|
||||
}
|
||||
|
||||
function worked_grid_before($gridsquare, $type, $band, $mode)
|
||||
{
|
||||
if (strlen($gridsquare) < 4)
|
||||
|
|
|
|||
|
|
@ -1150,7 +1150,9 @@ class Logbook_model extends CI_Model {
|
|||
/* Callsign QRA */
|
||||
function call_qra($callsign) {
|
||||
$this->db->select('COL_CALL, COL_GRIDSQUARE, COL_TIME_ON');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$where = "COL_GRIDSQUARE != \"\"";
|
||||
|
||||
$this->db->where($where);
|
||||
|
|
@ -1170,7 +1172,9 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
function call_name($callsign) {
|
||||
$this->db->select('COL_CALL, COL_NAME, COL_TIME_ON');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$where = "COL_NAME != \"\"";
|
||||
|
||||
$this->db->where($where);
|
||||
|
|
@ -1190,15 +1194,17 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
function call_qslvia($callsign) {
|
||||
$this->db->select('COL_CALL, COL_QSL_VIA, COL_TIME_ON');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$where = "COL_NAME != \"\"";
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$where = "COL_QSL_VIA != \"\"";
|
||||
|
||||
$this->db->where($where);
|
||||
|
||||
$this->db->order_by("COL_TIME_ON", "desc");
|
||||
$this->db->limit(1);
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
$name = "";
|
||||
$qsl_via = "";
|
||||
if ($query->num_rows() > 0)
|
||||
{
|
||||
$data = $query->row();
|
||||
|
|
@ -1210,15 +1216,17 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
function call_state($callsign) {
|
||||
$this->db->select('COL_CALL, COL_STATE');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$where = "COL_NAME != \"\"";
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$where = "COL_STATE != \"\"";
|
||||
|
||||
$this->db->where($where);
|
||||
|
||||
$this->db->order_by("COL_TIME_ON", "desc");
|
||||
$this->db->limit(1);
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
$name = "";
|
||||
$qsl_state = "";
|
||||
if ($query->num_rows() > 0)
|
||||
{
|
||||
$data = $query->row();
|
||||
|
|
@ -1230,7 +1238,9 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
function call_us_county($callsign) {
|
||||
$this->db->select('COL_CALL, COL_CNTY');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
|
||||
$where = "COL_CNTY != \"\"";
|
||||
|
||||
$this->db->where($where);
|
||||
|
|
@ -1251,6 +1261,7 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
function call_qth($callsign) {
|
||||
$this->db->select('COL_CALL, COL_QTH, COL_TIME_ON');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$where = "COL_QTH != \"\"";
|
||||
|
||||
|
|
@ -1271,6 +1282,7 @@ class Logbook_model extends CI_Model {
|
|||
|
||||
function call_iota($callsign) {
|
||||
$this->db->select('COL_CALL, COL_IOTA, COL_TIME_ON');
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->where('COL_CALL', $callsign);
|
||||
$where = "COL_IOTA != \"\"";
|
||||
|
||||
|
|
|
|||
正在加载…
在新工单中引用