kopia lustrzana https://github.com/magicbug/Cloudlog
Resolves issue 1632. JSON-Array of stations will be returned if /index.php/api/station_info/[key] is called
rodzic
646bf737e0
commit
f938270f4c
|
@ -158,6 +158,30 @@ class API extends CI_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
function station_info($key) {
|
||||
$this->load->model('api_model');
|
||||
$this->load->model('stations');
|
||||
header("Content-type: application/json");
|
||||
if(substr($this->api_model->access($key),0,1) == 'r') { /* Checkpermission for _r_eading */
|
||||
$this->api_model->update_last_used($key);
|
||||
$userid = $this->api_model->key_userid($key);
|
||||
$station_ids = array();
|
||||
$stations=$this->stations->all_of_user($userid);
|
||||
foreach ($stations->result() as $row) {
|
||||
$result['station_id']=$row->station_id;
|
||||
$result['station_profile_name']=$row->station_profile_name;
|
||||
$result['station_gridsquare']=$row->station_gridsquare;
|
||||
$result['station_callsign']=$row->station_callsign;;
|
||||
$result['station_active']=$row->station_active;
|
||||
array_push($station_ids, $result);
|
||||
}
|
||||
echo json_encode($station_ids);
|
||||
} else {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "missing or invalid api key"]);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: search()
|
||||
// Handle search requests
|
||||
/*
|
||||
|
|
|
@ -23,9 +23,12 @@ class Stations extends CI_Model {
|
|||
return $this->db->get();
|
||||
}
|
||||
|
||||
function all_of_user() {
|
||||
function all_of_user($userid = null) {
|
||||
if ($userid == null) {
|
||||
$userid=$this->session->userdata('user_id'); // Fallback to session-uid, if userid is omitted
|
||||
}
|
||||
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end');
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
$this->db->where('user_id', $userid);
|
||||
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
|
||||
return $this->db->get('station_profile');
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue