Merge pull request #2465 from phl0/checkStationCallsign
Check station callsign in station profile
这个提交包含在:
		
						当前提交
						8400654d3d
					
				
					共有  2 个文件被更改,包括 19 次插入 和 2 次删除
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		正在加载…
	
		在新工单中引用