Merge pull request #2907 from hugosilvaparagramanet/bugfix/handle-qrz.com-not-found

Retry QRZ.com for compound callsigns
pull/2912/head
Peter Goodhall 2024-01-04 15:06:16 +00:00 zatwierdzone przez GitHub
commit cc7e473e6f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 34 dodań i 10 usunięć

Wyświetl plik

@ -4384,6 +4384,26 @@ function lotw_last_qsl_date($user_id) {
} }
} }
// This should be in a helper? copied from Logbook controller
function get_plaincall($callsign) {
$split_callsign=explode('/',$callsign);
if (count($split_callsign)==1) { // case F0ABC --> return cel 0 //
$lookupcall = $split_callsign[0];
} else if (count($split_callsign)==3) { // case EA/F0ABC/P --> return cel 1 //
$lookupcall = $split_callsign[1];
} else { // case F0ABC/P --> return cel 0 OR case EA/FOABC --> retunr 1 (normaly not exist) //
if (in_array(strtoupper($split_callsign[1]), array('P','M','MM','QRP','0','1','2','3','4','5','6','7','8','9'))) {
$lookupcall = $split_callsign[0];
} else if (strlen($split_callsign[1])>3) { // Last Element longer than 3 chars? Take that as call
$lookupcall = $split_callsign[1];
} else { // Last Element up to 3 Chars? Take first element as Call
$lookupcall = $split_callsign[0];
}
}
return $lookupcall;
}
public function loadCallBook($callsign, $use_fullname=false) public function loadCallBook($callsign, $use_fullname=false)
{ {
$callbook = null; $callbook = null;
@ -4405,6 +4425,10 @@ function lotw_last_qsl_date($user_id) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password')); $qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key); $this->session->set_userdata('qrz_session_key', $qrz_session_key);
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname); $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname);
// if we still got nothing, and it's a compound callsign, then try a search for the base call
if (($callbook['callsign'] ?? '') == '' && strpos($callsign,"/")!==false){
$callbook = $this->qrz->search($this->get_plaincall($callsign), $this->session->userdata('qrz_session_key'), $use_fullname);
}
} }
} }