mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Check station callsign in station profile
This commit is contained in:
@@ -185,8 +185,6 @@ class API extends CI_Controller {
|
||||
die();
|
||||
}
|
||||
|
||||
$this->api_model->update_last_used($obj['key']);
|
||||
|
||||
if($obj['type'] == "adif" && $obj['string'] != "") {
|
||||
// Load the logbook model for adding QSO records
|
||||
$this->load->model('logbook_model');
|
||||
@@ -207,6 +205,14 @@ class API extends CI_Controller {
|
||||
|
||||
|
||||
if(isset($obj['station_profile_id'])) {
|
||||
if(isset($record['station_callsign']) && $this->stations->check_station_against_callsign($obj['station_profile_id'], $record['station_callsign']) == false) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "station callsign does not match station callsign in station profile."]);
|
||||
die();
|
||||
}
|
||||
|
||||
$this->api_model->update_last_used($obj['key']);
|
||||
|
||||
$this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, NULL, false, false, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -485,6 +485,17 @@ class Stations extends CI_Model {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function check_station_against_callsign($stationid, $callsign) {
|
||||
$this->db->select('station_id');
|
||||
$this->db->where('station_callsign', $callsign);
|
||||
$this->db->where('station_id', $stationid);
|
||||
$query = $this->db->get('station_profile');
|
||||
if ($query->num_rows() == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user