Merge pull request #694 from jsb2092/master
Added support for lookups in services for more detailed information when logged in
这个提交包含在:
当前提交
fa1bb549ee
共有 5 个文件被更改,包括 143 次插入 和 101 次删除
|
|
@ -155,38 +155,8 @@ class Logbook extends CI_Controller {
|
|||
}
|
||||
|
||||
|
||||
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');
|
||||
$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname'));
|
||||
|
||||
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))
|
||||
{
|
||||
|
|
@ -553,8 +523,14 @@ class Logbook extends CI_Controller {
|
|||
$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);
|
||||
}
|
||||
$data= $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
||||
|
||||
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'));
|
||||
if (empty($data['callsign']))
|
||||
{
|
||||
$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);
|
||||
$data = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
||||
}
|
||||
}
|
||||
|
||||
// There's no hamli integration? Disabled for now.
|
||||
|
|
@ -611,7 +587,7 @@ class Logbook extends CI_Controller {
|
|||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
||||
}
|
||||
|
||||
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'));
|
||||
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
||||
} else {
|
||||
// Lookup using hamli
|
||||
$this->load->library('hamli');
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ class Hamqth {
|
|||
|
||||
public function search($callsign, $key)
|
||||
{
|
||||
|
||||
$data = null;
|
||||
try {
|
||||
// URL to the XML Source
|
||||
$xml_feed_url = 'https://www.hamqth.com/xml.php?id=' . $key . '&callsign=' . $callsign . '&prg=cloudlog';
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ class Hamqth {
|
|||
|
||||
// Create XML object
|
||||
$xml = simplexml_load_string($xml);
|
||||
if (empty($xml)) return;
|
||||
|
||||
// Return Required Fields
|
||||
$data['callsign'] = (string)$xml->search->callsign;
|
||||
|
|
@ -90,7 +92,8 @@ class Hamqth {
|
|||
$data['state'] = null;
|
||||
$data['us_county'] = null;
|
||||
}
|
||||
|
||||
} finally {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,9 +54,10 @@ class Qrz {
|
|||
}
|
||||
|
||||
|
||||
public function search($callsign, $key)
|
||||
public function search($callsign, $key, $use_fullname)
|
||||
{
|
||||
|
||||
$data = null;
|
||||
try {
|
||||
// URL to the XML Source
|
||||
$xml_feed_url = 'http://xmldata.qrz.com/xml/current/?s=' . $key . ';callsign=' . $callsign . '';
|
||||
|
||||
|
|
@ -70,10 +71,17 @@ class Qrz {
|
|||
|
||||
// Create XML object
|
||||
$xml = simplexml_load_string($xml);
|
||||
if (empty($xml)) return;
|
||||
|
||||
// Return Required Fields
|
||||
$data['callsign'] = (string)$xml->Callsign->call;
|
||||
|
||||
if ($use_fullname === true) {
|
||||
$data['name'] = (string)$xml->Callsign->fname. ' ' . (string)$xml->Callsign->name;
|
||||
} else {
|
||||
$data['name'] = (string)$xml->Callsign->fname;
|
||||
}
|
||||
$data['name'] = trim($data['name']);
|
||||
$data['gridsquare'] = (string)$xml->Callsign->grid;
|
||||
$data['city'] = (string)$xml->Callsign->addr2;
|
||||
$data['lat'] = (string)$xml->Callsign->lat;
|
||||
|
|
@ -88,8 +96,9 @@ class Qrz {
|
|||
$data['state'] = null;
|
||||
$data['us_county'] = null;
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1594,7 +1594,7 @@ class Logbook_model extends CI_Model {
|
|||
$entity = $this->get_entity($record['dxcc']);
|
||||
$dxcc = array($record['dxcc'], $entity['name']);
|
||||
} else {
|
||||
$dxcc = NULL;
|
||||
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
||||
}
|
||||
} else {
|
||||
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
||||
|
|
@ -1607,8 +1607,10 @@ class Logbook_model extends CI_Model {
|
|||
if(isset($record['country'])) {
|
||||
$country = $record['country'];
|
||||
} else {
|
||||
if (isset($dxcc[1])) {
|
||||
$country = ucwords(strtolower($dxcc[1]));
|
||||
}
|
||||
}
|
||||
|
||||
// RST recevied
|
||||
if(isset($record['rst_rcvd'])) {
|
||||
|
|
@ -2337,6 +2339,54 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
public function loadCallBook($callsign, $use_fullname=false)
|
||||
{
|
||||
$callbook = null;
|
||||
try {
|
||||
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'), $use_fullname);
|
||||
|
||||
// if we got nothing, it's probably because our session key is invalid, try again
|
||||
if (!isset($callbook['callsign']))
|
||||
{
|
||||
$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'), $use_fullname);
|
||||
}
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
return $callbook;
|
||||
}
|
||||
}
|
||||
|
||||
public function update_all_station_ids() {
|
||||
|
||||
|
|
@ -2464,4 +2514,6 @@ function validateADIFDate($date, $format = 'Ymd')
|
|||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -40,10 +40,12 @@ $config['display_freq'] = false;
|
|||
|
|
||||
| 'qrz_username' QRZ.com user login
|
||||
| 'qrz_password' QRZ.com user password
|
||||
| 'use_fullname' Get full names from QRZ, may not be GDPR compliant
|
||||
*/
|
||||
|
||||
$config['qrz_username'] = "";
|
||||
$config['qrz_password'] = "";
|
||||
$config['use_fullname'] = false;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
正在加载…
在新工单中引用