kopia lustrzana https://github.com/magicbug/Cloudlog
Does a lookup on qrz/hamqth on api or when entering by hand. Names and grid squares are returned and populated if not already set. Full names are set since they are not shown unless logged in.
rodzic
4d73a50ef6
commit
8660d3d3ce
|
@ -138,39 +138,8 @@ class Logbook extends CI_Controller {
|
|||
return;
|
||||
}
|
||||
|
||||
$callbook = $this->logbook_model->loadCallBook($callsign);
|
||||
|
||||
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null)
|
||||
{
|
||||
// Lookup using QRZ
|
||||
$this->load->library('qrz');
|
||||
|
||||
if(!$this->session->userdata('qrz_session_key')) {
|
||||
$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);
|
||||
}
|
||||
|
||||
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
|
||||
}
|
||||
|
||||
if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null)
|
||||
{
|
||||
// Load the HamQTH library
|
||||
$this->load->library('hamqth');
|
||||
|
||||
if(!$this->session->userdata('hamqth_session_key')) {
|
||||
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
||||
}
|
||||
|
||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
||||
|
||||
// If HamQTH session has expired, start a new session and retry the search.
|
||||
if($callbook['error'] == "Session does not exist or expired") {
|
||||
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($callbook))
|
||||
{
|
||||
|
|
|
@ -1791,6 +1791,16 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
// if we are doing lookups and grid square and name aren't set, do the lookup now
|
||||
|
||||
$callbook = $this->loadCallBook(strtoupper($record['call']));
|
||||
if (isset($callbook)) {
|
||||
$record['name']= $callbook['name'];
|
||||
if (empty($record['gridsquare'])) {
|
||||
$record['gridsquare'] = $callbook['gridsquare'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$skip)
|
||||
{
|
||||
// Create array with QSO Data use ?:
|
||||
|
@ -2158,6 +2168,42 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
public function loadCallBook($callsign)
|
||||
{
|
||||
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null)
|
||||
{
|
||||
// Lookup using QRZ
|
||||
$this->load->library('qrz');
|
||||
|
||||
if(!$this->session->userdata('qrz_session_key')) {
|
||||
$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);
|
||||
}
|
||||
|
||||
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
|
||||
}
|
||||
|
||||
if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null)
|
||||
{
|
||||
// Load the HamQTH library
|
||||
$this->load->library('hamqth');
|
||||
|
||||
if(!$this->session->userdata('hamqth_session_key')) {
|
||||
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
||||
}
|
||||
|
||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
||||
|
||||
// If HamQTH session has expired, start a new session and retry the search.
|
||||
if($callbook['error'] == "Session does not exist or expired") {
|
||||
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
||||
}
|
||||
}
|
||||
return $callbook;
|
||||
}
|
||||
|
||||
public function update_all_station_ids() {
|
||||
|
||||
|
@ -2271,4 +2317,6 @@ function validateADIFDate($date, $format = 'Ymd')
|
|||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
Ładowanie…
Reference in New Issue