diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
index fc529f452..bbdf05827 100644
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -921,9 +921,16 @@ class Logbook extends CI_Controller {
$this->load->model('logbook_model');
$callsigninfo['grid_worked'] = $this->logbook_model->check_if_grid_worked_in_logbook(strtoupper(substr($callsigninfo['callsign']['gridsquare'],0,4)), null, $band)->num_rows();
}
-
- if (isset($callsigninfo['callsign']['error'])) {
- $callsigninfo['error'] = $callsigninfo['callsign']['error'];
+ $source_callbooks = $this->config->item('callbook');
+ if (is_array($source_callbooks)) {
+ $callsigninfo['error'] = ''.__('All callbook lookups failed or provided no results.').'';
+ foreach($source_callbooks as $source) {
+ $callsigninfo['error'] .= "
".$callsigninfo['callsign']['error_'.$source.'_name'].': '.$callsigninfo['callsign']['error_'.$source];
+ }
+ } else {
+ if (isset($callsigninfo['callsign']['error'])) {
+ $callsigninfo['error'] = $callsigninfo['callsign']['error'];
+ }
}
$callsigninfo['lookupcall'] = strtoupper($lookupcall);
diff --git a/application/libraries/Callbook.php b/application/libraries/Callbook.php
index 6d20466cb..a4f572f94 100644
--- a/application/libraries/Callbook.php
+++ b/application/libraries/Callbook.php
@@ -20,6 +20,7 @@ class Callbook {
public function getCallbookData($callsign) {
// Load callbook configuration from config.php
$source_callbooks = $this->ci->config->item('callbook');
+ $callbook_errors = array();
// Check if the source callbook is a single element or an array
if (is_array($source_callbooks)) {
@@ -28,10 +29,12 @@ class Callbook {
$callbook = $this->queryCallbook($callsign, $source);
if (!isset($callbook['error']) || $callbook['error'] == '') {
break;
+ } else {
+ $callbook_errors['error_'.$source] = $callbook['error'];
+ $callbook_errors['error_'.$source.'_name'] = $callbook['source'];
}
}
- }
- else {
+ } else {
// Single callbook lookup (default behavior)
$callbook = $this->queryCallbook($callsign, $source_callbooks);
}
@@ -47,38 +50,30 @@ class Callbook {
$callbook['gridsquare'] = '';
}
+ if (isset($callbook['error']) && $callbook['error'] != '') {
+ if (is_array($source_callbooks)) {
+ foreach ($source_callbooks as $source) {
+ $callbook['error_'.$source] = $callbook_errors['error_'.$source];
+ $callbook['error_'.$source.'_name'] = $callbook_errors['error_'.$source.'_name'];
+ }
+ }
+ }
return $callbook;
}
function queryCallbook($callsign, $source) {
switch ($source) {
case 'qrz':
- if ($this->ci->config->item('qrz_username') == null || $this->ci->config->item('qrz_password') == null) {
- $callbook['error'] = 'Lookup not configured. Please review configuration.';
- } else {
- $callbook = $this->qrz($this->ci->config->item('qrz_username'), $this->ci->config->item('qrz_password'), $callsign, $this->ci->config->item('use_fullname'));
- }
+ $callbook = $this->qrz($callsign, $this->ci->config->item('use_fullname'));
break;
case 'qrzcq':
- if ($this->ci->config->item('qrzcq_username') == null || $this->ci->config->item('qrzcq_password') == null) {
- $callbook['error'] = 'Lookup not configured. Please review configuration.';
- } else {
- $callbook = $this->qrzcq($this->ci->config->item('qrzcq_username'), $this->ci->config->item('qrzcq_password'), $callsign);
- }
+ $callbook = $this->qrzcq($callsign);
break;
case 'hamqth':
- if ($this->ci->config->item('hamqth_username') == null || $this->ci->config->item('hamqth_password') == null) {
- $callbook['error'] = 'Lookup not configured. Please review configuration.';
- } else {
- $callbook = $this->hamqth($this->ci->config->item('hamqth_username'), $this->ci->config->item('hamqth_password'), $callsign);
- }
+ $callbook = $this->hamqth($callsign);
break;
case 'qrzru':
- if ($this->ci->config->item('qrzru_username') == null || $this->ci->config->item('qrzru_password') == null) {
- $callbook['error'] = 'Lookup not configured. Please review configuration.';
- } else {
- $callbook = $this->qrzru($this->ci->config->item('qrzru_username'), $this->ci->config->item('qrzru_password'), $callsign);
- }
+ $callbook = $this->qrzru($callsign);
break;
default:
$callbook['error'] = 'No callbook defined. Please review configuration.';
@@ -88,122 +83,156 @@ class Callbook {
return $callbook;
}
- function qrz($username, $password, $callsign, $fullname) {
+ function qrz($callsign, $fullname) {
if (!$this->ci->load->is_loaded('qrz')) {
$this->ci->load->library('qrz');
}
+ if ($this->ci->config->item('qrz_username') == null || $this->ci->config->item('qrz_password') == null) {
+ $callbook['error'] = 'Lookup not configured. Please review configuration.';
+ $callbook['source'] = $this->ci->qrz->sourcename();
+ } else {
+ $username = $this->ci->config->item('qrz_username');
+ $password = $this->ci->config->item('qrz_password');
- if (!$this->ci->session->userdata('qrz_session_key')) {
- $qrz_session_key = $this->ci->qrz->session($username, $password);
- $this->ci->session->set_userdata('qrz_session_key', $qrz_session_key);
- }
+ if (!$this->ci->session->userdata('qrz_session_key')) {
+ $qrz_session_key = $this->ci->qrz->session($username, $password);
+ $this->ci->session->set_userdata('qrz_session_key', $qrz_session_key);
+ }
- $callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname);
-
- if ($callbook['error'] ?? '' == 'Invalid session key') {
- $qrz_session_key = $this->ci->qrz->session($username, $password);
- $this->ci->session->set_userdata('qrz_session_key', $qrz_session_key);
$callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname);
- }
- if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
- $plaincall = $this->get_plaincall($callsign);
- // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
- $callbook = $this->ci->qrz->search($plaincall, $this->ci->session->userdata('qrz_session_key'), $fullname, true);
+ if ($callbook['error'] ?? '' == 'Invalid session key') {
+ $qrz_session_key = $this->ci->qrz->session($username, $password);
+ $this->ci->session->set_userdata('qrz_session_key', $qrz_session_key);
+ $callbook = $this->ci->qrz->search($callsign, $this->ci->session->userdata('qrz_session_key'), $fullname);
+ }
+
+ if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
+ $plaincall = $this->get_plaincall($callsign);
+ // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
+ $callbook = $this->ci->qrz->search($plaincall, $this->ci->session->userdata('qrz_session_key'), $fullname, true);
+ }
}
+ $callbook['source'] = $this->ci->qrz->sourcename();
return $callbook;
}
- function qrzcq($username, $password, $callsign) {
+ function qrzcq($callsign) {
if (!$this->ci->load->is_loaded('qrzcq')) {
$this->ci->load->library('qrzcq');
}
+ if ($this->ci->config->item('qrzcq_username') == null || $this->ci->config->item('qrzcq_password') == null) {
+ $callbook['error'] = 'Lookup not configured. Please review configuration.';
+ $callbook['source'] = $this->ci->qrzcq->sourcename();
+ } else {
+ $username = $this->ci->config->item('qrzcq_username');
+ $password = $this->ci->config->item('qrzcq_password');
- if (!$this->ci->session->userdata('qrzcq_session_key')) {
- $result = $this->ci->qrzcq->session($username, $password);
- if ($result[0] == 0) {
- $this->ci->session->set_userdata('qrzcq_session_key', $result[1]);
- } else {
- $data['error'] = __("QRZCQ Error").": ".$result[1];
- return $data;
+ if (!$this->ci->session->userdata('qrzcq_session_key')) {
+ $result = $this->ci->qrzcq->session($username, $password);
+ if ($result[0] == 0) {
+ $this->ci->session->set_userdata('qrzcq_session_key', $result[1]);
+ } else {
+ $data['error'] = __("QRZCQ Error").": ".$result[1];
+ $data['source'] = $this->ci->qrzcq->sourcename();
+ return $data;
+ }
+ }
+
+ $callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'));
+
+ if ($callbook['error'] ?? '' == 'Invalid session key') {
+ $qrzcq_session_key = $this->ci->qrzcq->session($username, $password);
+ $this->ci->session->set_userdata('qrzcq_session_key', $qrzcq_session_key);
+ $callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'));
+ }
+
+ if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
+ $plaincall = $this->get_plaincall($callsign);
+ // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
+ $callbook = $this->ci->qrzcq->search($plaincall, $this->ci->session->userdata('qrzcq_session_key'), true);
}
}
-
- $callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'));
-
- if ($callbook['error'] ?? '' == 'Invalid session key') {
- $qrzcq_session_key = $this->ci->qrzcq->session($username, $password);
- $this->ci->session->set_userdata('qrzcq_session_key', $qrzcq_session_key);
- $callbook = $this->ci->qrzcq->search($callsign, $this->ci->session->userdata('qrzcq_session_key'));
- }
-
- if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
- $plaincall = $this->get_plaincall($callsign);
- // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
- $callbook = $this->ci->qrzcq->search($plaincall, $this->ci->session->userdata('qrzcq_session_key'), true);
- }
+ $callbook['source'] = $this->ci->qrzcq->sourcename();
return $callbook;
}
- function hamqth($username, $password, $callsign) {
+ function hamqth($callsign) {
// Load the HamQTH library
if (!$this->ci->load->is_loaded('hamqth')) {
$this->ci->load->library('hamqth');
}
+ if ($this->ci->config->item('hamqth_username') == null || $this->ci->config->item('hamqth_password') == null) {
+ $callbook['error'] = 'Lookup not configured. Please review configuration.';
+ $callbook['source'] = $this->ci->hamqth->sourcename();
+ } else {
+ $username = $this->ci->config->item('hamqth_username');
+ $password = $this->ci->config->item('hamqth_password');
- if (!$this->ci->session->userdata('hamqth_session_key')) {
- $hamqth_session_key = $this->ci->hamqth->session($username, $password);
- if ($hamqth_session_key == false) {
- $callbook['error'] = __("Error obtaining a session key for HamQTH query");
- return $callbook;
- } else {
+ if (!$this->ci->session->userdata('hamqth_session_key')) {
+ $hamqth_session_key = $this->ci->hamqth->session($username, $password);
+ if ($hamqth_session_key == false) {
+ $callbook['error'] = __("Error obtaining a session key for HamQTH query");
+ $callbook['source'] = $this->ci->hamqth->sourcename();
+ return $callbook;
+ } else {
+ $this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
+ }
+ }
+
+ $callbook = $this->ci->hamqth->search($callsign, $this->ci->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->ci->hamqth->session($username, $password);
$this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
+ $callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'));
+ }
+
+ if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
+ $plaincall = $this->get_plaincall($callsign);
+ // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
+ $callbook = $this->ci->hamqth->search($plaincall, $this->ci->session->userdata('hamqth_session_key'), true);
}
}
-
- $callbook = $this->ci->hamqth->search($callsign, $this->ci->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->ci->hamqth->session($username, $password);
- $this->ci->session->set_userdata('hamqth_session_key', $hamqth_session_key);
- $callbook = $this->ci->hamqth->search($callsign, $this->ci->session->userdata('hamqth_session_key'));
- }
-
- if (strpos($callbook['error'] ?? '', 'Not found') !== false && strpos($callsign, "/") !== false) {
- $plaincall = $this->get_plaincall($callsign);
- // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
- $callbook = $this->ci->hamqth->search($plaincall, $this->ci->session->userdata('hamqth_session_key'), true);
- }
+ $callbook['source'] = $this->ci->hamqth->sourcename();
return $callbook;
}
- function qrzru($username, $password, $callsign) {
+ function qrzru($callsign) {
if (!$this->ci->load->is_loaded('qrzru')) {
$this->ci->load->library('qrzru');
}
+ if ($this->ci->config->item('qrzru_username') == null || $this->ci->config->item('qrzru_password') == null) {
+ $callbook['error'] = 'Lookup not configured. Please review configuration.';
+ $callbook['source'] = $this->ci->qrzru->sourcename();
+ } else {
+ $username = $this->ci->config->item('qrzru_username');
+ $password = $this->ci->config->item('qrzru_password');
- if (!$this->ci->session->userdata('qrzru_session_key')) {
- $result = $this->ci->qrzru->session($username, $password);
- $this->ci->session->set_userdata('qrzru_session_key', $result);
- }
+ if (!$this->ci->session->userdata('qrzru_session_key')) {
+ $result = $this->ci->qrzru->session($username, $password);
+ $this->ci->session->set_userdata('qrzru_session_key', $result);
+ }
- $callbook = $this->ci->qrzru->search($callsign, $this->ci->session->userdata('qrzru_session_key'));
-
- if ($callbook['error'] ?? '' == 'Session does not exist or expired') {
- $qrzru_session_key = $this->ci->qrzru->session($username, $password);
- $this->ci->session->set_userdata('qrzru_session_key', $qrzru_session_key);
$callbook = $this->ci->qrzru->search($callsign, $this->ci->session->userdata('qrzru_session_key'));
- }
- if (strpos($callbook['error'] ?? '', 'Callsign not found') !== false && strpos($callsign, "/") !== false) {
- $plaincall = $this->get_plaincall($callsign);
- // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
- $callbook = $this->ci->qrzru->search($plaincall, $this->ci->session->userdata('qrzru_session_key'), true);
+ if ($callbook['error'] ?? '' == 'Session does not exist or expired') {
+ $qrzru_session_key = $this->ci->qrzru->session($username, $password);
+ $this->ci->session->set_userdata('qrzru_session_key', $qrzru_session_key);
+ $callbook = $this->ci->qrzru->search($callsign, $this->ci->session->userdata('qrzru_session_key'));
+ }
+
+ if (strpos($callbook['error'] ?? '', 'Callsign not found') !== false && strpos($callsign, "/") !== false) {
+ $plaincall = $this->get_plaincall($callsign);
+ // Now try again but give back reduced data, as we can't validate location and stuff (true at the end)
+ $callbook = $this->ci->qrzru->search($plaincall, $this->ci->session->userdata('qrzru_session_key'), true);
+ }
}
+ $callbook['source'] = $this->ci->qrzru->sourcename();
return $callbook;
}
diff --git a/application/libraries/Hamqth.php b/application/libraries/Hamqth.php
index 44ac17e35..c71005a45 100644
--- a/application/libraries/Hamqth.php
+++ b/application/libraries/Hamqth.php
@@ -7,6 +7,8 @@
class Hamqth {
+ public $callbookname = 'HamQTH';
+
// Return session key
public function session($username, $password) {
// URL to the XML Source
@@ -126,8 +128,11 @@ class Hamqth {
}
} finally {
- $data['source'] = 'HamQTH';
return $data;
}
}
+
+ public function sourcename() {
+ return $this->callbookname;
+ }
}
diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php
index 6c536a603..24c37b5c9 100644
--- a/application/libraries/Qrz.php
+++ b/application/libraries/Qrz.php
@@ -4,9 +4,10 @@
Controls the interaction with the QRZ.com Subscription based XML API.
*/
-
class Qrz {
+ public $callbookname = 'QRZ';
+
// Return session key
public function session($username, $password) {
// URL to the XML Source
@@ -60,7 +61,6 @@ class Qrz {
return true;
}
-
public function search($callsign, $key, $use_fullname = false, $reduced = false) {
$data = null;
$ci = & get_instance();
@@ -186,8 +186,12 @@ class Qrz {
$data['cqzone'] = '';
}
} finally {
- $data['source'] = 'QRZ';
return $data;
}
}
+
+ public function sourcename() {
+ return $this->callbookname;
+ }
+
}
diff --git a/application/libraries/Qrzcq.php b/application/libraries/Qrzcq.php
index 70e549b38..7abbfc84c 100644
--- a/application/libraries/Qrzcq.php
+++ b/application/libraries/Qrzcq.php
@@ -7,6 +7,8 @@
class Qrzcq {
+ public $callbookname = 'QRZCQ';
+
// Return session key
public function session($username, $password) {
// URL to the XML Source
@@ -144,8 +146,11 @@ class Qrzcq {
}
} finally {
- $data['source'] = 'QRZCQ';
return $data;
}
}
+
+ public function sourcename() {
+ return $this->callbookname;
+ }
}
diff --git a/application/libraries/Qrzru.php b/application/libraries/Qrzru.php
index c8427cf6f..82493ae9b 100644
--- a/application/libraries/Qrzru.php
+++ b/application/libraries/Qrzru.php
@@ -7,6 +7,8 @@
class Qrzru {
+ public $callbookname = 'QRZ.ru';
+
// Return session key
public function session($username, $password) {
// URL to the XML Source
@@ -115,8 +117,11 @@ class Qrzru {
$data['cqz'] = '';
}
} finally {
- $data['source'] = 'QRZ.ru';
return $data;
}
}
+
+ public function sourcename() {
+ return $this->callbookname;
+ }
}