Refactor Logbook_model formatting and indentation

Standardized code formatting and indentation throughout Logbook_model.php for improved readability and maintainability. No functional changes were made; only whitespace, comment alignment, and consistent brace placement were updated.
这个提交包含在:
Peter Goodhall 2025-08-18 14:34:32 +01:00
父节点 adf658903b
当前提交 46155ba2de

查看文件

@ -118,7 +118,6 @@ class Logbook_model extends CI_Model
} }
if ($this->input->post('dxcc_id') == "") { if ($this->input->post('dxcc_id') == "") {
$dxcc = $this->check_dxcc_table(strtoupper(trim($callsign)), $datetime); $dxcc = $this->check_dxcc_table(strtoupper(trim($callsign)), $datetime);
if (empty($dxcc[0])) { if (empty($dxcc[0])) {
$dxcc_id = null; $dxcc_id = null;
@ -126,13 +125,12 @@ class Logbook_model extends CI_Model
$dxcc_id = $dxcc[0]; $dxcc_id = $dxcc[0];
} }
} else { } else {
// if $country isn't empty // if $country isn't empty and dxcc_id is 0 use the DXCC ID from the callsign lookup
if (!empty($country) && $this->input->post('dxcc_id') == "0") { if (!empty($country) && $this->input->post('dxcc_id') == "0") {
$dxcc_id = $dxcc_id; $dxcc_id = $dxcc_id;
} else { } else {
$dxcc_id = $this->input->post('dxcc_id'); $dxcc_id = $this->input->post('dxcc_id');
} }
} }
if ($this->input->post('continent') == "") { if ($this->input->post('continent') == "") {
@ -194,13 +192,13 @@ class Logbook_model extends CI_Model
case 'power': case 'power':
$qso_rx_power = $srx_string; $qso_rx_power = $srx_string;
break; break;
// Example for more sophisticated exchanges and their split into the db: // Example for more sophisticated exchanges and their split into the db:
//case 'name/power': //case 'name/power':
// if (strlen($srx_string) == 0) break; // if (strlen($srx_string) == 0) break;
// $exch_pt = explode(" ",$srx_string); // $exch_pt = explode(" ",$srx_string);
// $qso_name = $exch_pt[0]; // $qso_name = $exch_pt[0];
// if (count($exch_pt)>1) $qso_power = $exch_pt[1]; // if (count($exch_pt)>1) $qso_power = $exch_pt[1];
// break; // break;
default: default:
} }
} }
@ -3008,7 +3006,8 @@ class Logbook_model extends CI_Model
} }
// Consolidated method to get all country statistics in one query // Consolidated method to get all country statistics in one query
function get_countries_statistics_consolidated($StationLocationsArray = null) { function get_countries_statistics_consolidated($StationLocationsArray = null)
{
if ($StationLocationsArray == null) { if ($StationLocationsArray == null) {
$CI = &get_instance(); $CI = &get_instance();
$CI->load->model('logbooks_model'); $CI->load->model('logbooks_model');
@ -4410,13 +4409,13 @@ class Logbook_model extends CI_Model
public function get_entity($dxcc) public function get_entity($dxcc)
{ {
$sql = "SELECT name, cqz, lat, `long` FROM dxcc_entities WHERE adif = ?"; $sql = "SELECT name, cqz, lat, `long` FROM dxcc_entities WHERE adif = ?";
$query = $this->db->query($sql, array($dxcc)); $query = $this->db->query($sql, array($dxcc));
if ($query->num_rows() > 0) { if ($query->num_rows() > 0) {
return $query->row_array(); return $query->row_array();
} }
return ''; return '';
} }
/* /*
@ -4507,37 +4506,37 @@ class Logbook_model extends CI_Model
foreach ($r->result_array() as $row) { foreach ($r->result_array() as $row) {
$callsign = $row['COL_CALL']; $callsign = $row['COL_CALL'];
if ($this->session->userdata('callbook_type') == "QRZ") { if ($this->session->userdata('callbook_type') == "QRZ") {
// Lookup using QRZ // Lookup using QRZ
$this->load->library('qrz'); $this->load->library('qrz');
// Load the encryption library // Load the encryption library
$this->load->library('encryption'); $this->load->library('encryption');
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('qrz_session_key')) { if (!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_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')); $callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
} }
if ($this->session->userdata('callbook_type') == "HamQTH") { if ($this->session->userdata('callbook_type') == "HamQTH") {
// Load the HamQTH library // Load the HamQTH library
$this->load->library('hamqth'); $this->load->library('hamqth');
// Load the encryption library // Load the encryption library
$this->load->library('encryption'); $this->load->library('encryption');
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('hamqth_session_key')) { if (!$this->session->userdata('hamqth_session_key')) {
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
} }
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key')); $callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
@ -4659,7 +4658,7 @@ class Logbook_model extends CI_Model
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('qrz_session_key')) { if (!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password); $qrz_session_key = $this->qrz->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('qrz_session_key', $qrz_session_key); $this->session->set_userdata('qrz_session_key', $qrz_session_key);
} }
@ -4688,7 +4687,7 @@ class Logbook_model extends CI_Model
// Decrypt the password // Decrypt the password
$decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password')); $decrypted_password = $this->encryption->decrypt($this->session->userdata('callbook_password'));
if(!$this->session->userdata('hamqth_session_key')) { if (!$this->session->userdata('hamqth_session_key')) {
$hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password); $hamqth_session_key = $this->hamqth->session($this->session->userdata('callbook_username'), $decrypted_password);
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
} }
@ -4863,7 +4862,7 @@ class Logbook_model extends CI_Model
// [JSON PLOT] return array for plot qso for map // // [JSON PLOT] return array for plot qso for map //
public function get_plot_array_for_map($qsos_result, $isVisitor = false) public function get_plot_array_for_map($qsos_result, $isVisitor = false)
{ {
$this->load->library('qra'); $this->load->library('qra');
$CI = &get_instance(); $CI = &get_instance();
$CI->load->library('DxccFlag'); $CI->load->library('DxccFlag');
@ -4876,7 +4875,7 @@ class Logbook_model extends CI_Model
$plot['label'] = $row->COL_CALL; $plot['label'] = $row->COL_CALL;
$plot['callsign'] = $row->COL_CALL; $plot['callsign'] = $row->COL_CALL;
$flag = strtolower($CI->dxccflag->getISO($row->COL_DXCC)); $flag = strtolower($CI->dxccflag->getISO($row->COL_DXCC));
$plot['flag'] = '<span data-bs-toggle="tooltip" title="' . ucwords(strtolower(($row->name==null?"- NONE -":$row->name))) . '"><span class="fi fi-' . $flag .'"></span></span> '; $plot['flag'] = '<span data-bs-toggle="tooltip" title="' . ucwords(strtolower(($row->name == null ? "- NONE -" : $row->name))) . '"><span class="fi fi-' . $flag . '"></span></span> ';
$plot['html'] = ($row->COL_GRIDSQUARE != null ? "<b>Grid:</b> " . $row->COL_GRIDSQUARE . "<br />" : ""); $plot['html'] = ($row->COL_GRIDSQUARE != null ? "<b>Grid:</b> " . $row->COL_GRIDSQUARE . "<br />" : "");
$plot['html'] .= "<b>Date/Time:</b> " . $row->COL_TIME_ON . "<br />"; $plot['html'] .= "<b>Date/Time:</b> " . $row->COL_TIME_ON . "<br />";
$plot['html'] .= ($row->COL_SAT_NAME != null) ? ("<b>SAT:</b> " . $row->COL_SAT_NAME . "<br />") : ("<b>Band:</b> " . $row->COL_BAND . " "); $plot['html'] .= ($row->COL_SAT_NAME != null) ? ("<b>SAT:</b> " . $row->COL_SAT_NAME . "<br />") : ("<b>Band:</b> " . $row->COL_BAND . " ");
@ -4937,12 +4936,13 @@ class Logbook_model extends CI_Model
} }
/** /**
* Processes a batch of QRZ ADIF records for efficient database updates. * Processes a batch of QRZ ADIF records for efficient database updates.
* *
* @param array $batch_data Array of records from the ADIF file. * @param array $batch_data Array of records from the ADIF file.
* @return string HTML table rows for the processed batch. * @return string HTML table rows for the processed batch.
*/ */
public function process_qrz_batch($batch_data) { public function process_qrz_batch($batch_data)
{
$table = ""; $table = "";
$update_batch_data = []; $update_batch_data = [];
$this->load->model('Stations'); $this->load->model('Stations');
@ -4952,14 +4952,14 @@ class Logbook_model extends CI_Model
} }
// Step 1: Build WHERE clause for fetching potential matches // Step 1: Build WHERE clause for fetching potential matches
$this->db->select($this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_MODE, '); $this->db->select($this->config->item('table_name') . '.COL_PRIMARY_KEY, ' . $this->config->item('table_name') . '.COL_CALL, ' . $this->config->item('table_name') . '.COL_TIME_ON, ' . $this->config->item('table_name') . '.COL_BAND, ' . $this->config->item('table_name') . '.COL_MODE, ');
$this->db->from($this->config->item('table_name')); $this->db->from($this->config->item('table_name'));
$this->db->group_start(); // Start grouping OR conditions $this->db->group_start(); // Start grouping OR conditions
foreach ($batch_data as $record) { foreach ($batch_data as $record) {
$this->db->or_group_start(); // Start group for this record's AND conditions $this->db->or_group_start(); // Start group for this record's AND conditions
$this->db->where($this->config->item('table_name').'.COL_CALL', $record['call']); $this->db->where($this->config->item('table_name') . '.COL_CALL', $record['call']);
$this->db->like($this->config->item('table_name').'.COL_TIME_ON', $record['time_on'], 'after'); $this->db->like($this->config->item('table_name') . '.COL_TIME_ON', $record['time_on'], 'after');
$this->db->where($this->config->item('table_name').'.COL_BAND', $record['band']); $this->db->where($this->config->item('table_name') . '.COL_BAND', $record['band']);
$this->db->group_end(); // End group for this record's AND conditions $this->db->group_end(); // End group for this record's AND conditions
} }
$this->db->group_end(); // End grouping OR conditions $this->db->group_end(); // End grouping OR conditions
@ -4971,7 +4971,7 @@ class Logbook_model extends CI_Model
// Index DB results for faster lookup // Index DB results for faster lookup
$indexed_results = []; $indexed_results = [];
foreach ($db_results as $row) { foreach ($db_results as $row) {
$time = substr($row['COL_TIME_ON'], 0, 16); $time = substr($row['COL_TIME_ON'], 0, 16);
$key = $row['COL_CALL'] . '|' . $time . '|' . $row['COL_BAND']; $key = $row['COL_CALL'] . '|' . $time . '|' . $row['COL_BAND'];
$indexed_results[$key] = $row['COL_PRIMARY_KEY']; $indexed_results[$key] = $row['COL_PRIMARY_KEY'];
} }
@ -5020,7 +5020,8 @@ class Logbook_model extends CI_Model
* @param string $user_format The user's preferred date format (e.g., 'd/m/Y', 'Y-m-d') * @param string $user_format The user's preferred date format (e.g., 'd/m/Y', 'Y-m-d')
* @return string Returns date in Y-m-d format for database storage, or original input if parsing fails * @return string Returns date in Y-m-d format for database storage, or original input if parsing fails
*/ */
private function parse_user_date($date_input, $user_format = null) { private function parse_user_date($date_input, $user_format = null)
{
if (empty($date_input)) { if (empty($date_input)) {
return $date_input; return $date_input;
} }