[API][CAT] Fixes issue where user_id isn't getting added to the hardware entry

pull/1218/head
Peter Goodhall 2021-09-28 17:18:04 +01:00
rodzic 0f57e62a84
commit 8b1770feab
3 zmienionych plików z 20 dodań i 6 usunięć

Wyświetl plik

@ -8,6 +8,12 @@ class API extends CI_Controller {
}
function test() {
$this->load->model('api_model');
echo $this->api_model->key_userid('cl61533ebc1fbfa');
}
/*
TODOs
- Search Callsign (Return Json)
@ -476,8 +482,10 @@ class API extends CI_Controller {
die();
}
$user_id = $this->api_model->key_userid($obj['key']);
// Store Result to Database
$this->cat->update($obj);
$this->cat->update($obj, $user_id);
// Return Message

Wyświetl plik

@ -28,6 +28,12 @@ class API_Model extends CI_Model {
return $query->result_array()[0];
}
function key_userid($key) {
$this->db->where('key', $key);
$query = $this->db->get('api');
return $query->result_array()[0]['user_id'];
}
function update_key_description($key, $description) {

Wyświetl plik

@ -8,10 +8,10 @@
parent::__construct();
}
function update($result) {
function update($result, $user_id) {
$this->db->where('radio', $result['radio']);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('user_id', $user_id);
$query = $this->db->get('cat');
if ($query->num_rows() > 0)
@ -31,7 +31,7 @@
);
$this->db->where('id', $radio_id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('user_id', $user_id);
$this->db->update('cat', $data);
}
} else {
@ -64,7 +64,7 @@
'uplink_freq' => $result['uplink_freq'],
'downlink_mode' => $result['downlink_mode'],
'uplink_mode' => $result['uplink_mode'],
'user_id' => $this->session->userdata('user_id'),
'user_id' => $user_id,
);
} else {
$data = array(
@ -72,7 +72,7 @@
'frequency' => $result['frequency'],
'mode' => $result['mode'],
'timestamp' => $result['timestamp'],
'user_id' => $this->session->userdata('user_id'),
'user_id' => $user_id,
);
}