UUID for locations / export / import / create

This commit is contained in:
int2001
2025-11-05 11:37:43 +00:00
parent 45972218c7
commit 48b75d4c15
5 changed files with 33 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 262;
$config['migration_version'] = 263;
/*
|--------------------------------------------------------------------------

View File

@@ -599,6 +599,7 @@ class Stationsetup extends CI_Controller {
'hrdlog_username' => xss_clean($loc['hrdlog_username'] ?? null),
'eqslqthnickname' => xss_clean($loc['eqslqthnickname'] ?? null),
'webadifapiurl' => 'https://qo100dx.club/api',
'station_uuid' => xss_clean($loc['station_uuid'] ?? null),
'user_id' => $this->session->userdata('user_id'),
];

View File

@@ -0,0 +1,24 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_add_station_uuid extends CI_Migration
{
public function up()
{
$this->dbtry("ALTER TABLE station_profile ADD COLUMN station_uuid varchar(36) DEFAULT NULL AFTER webadifrealtime");
$this->dbtry("UPDATE station_profile SET station_uuid = UUID() WHERE station_uuid IS NULL");
}
public function down()
{
$this->dbtry("ALTER TABLE station_profile DROP COLUMN station_uuid");
}
function dbtry($what) {
try {
$this->db->query($what);
} catch (Exception $e) {
log_message("error", "Something gone wrong while altering station_uuid: ".$e." // Executing: ".$this->db->last_query());
}
}
}

View File

@@ -160,6 +160,7 @@ class Stations extends CI_Model {
'webadifapikey' => xss_clean($this->input->post('webadifapikey', true)),
'webadifapiurl' => 'https://qo100dx.club/api',
'webadifrealtime' => xss_clean($this->input->post('webadifrealtime', true)),
'station_uuid' => $this->db->query("SELECT UUID() as uuid")->row()->uuid,
);
// Insert Records & return insert id //

View File

@@ -234,7 +234,7 @@ class Stationsetup_model extends CI_Model {
}
function list_all_locations() {
$sql = "select dxcc_entities.end, station_profile.station_id, station_profile_name, station_profile.hrdlog_username, station_gridsquare, station_city, station_iota, station_sota, station_callsign, station_power, station_dxcc, dxcc_entities.name as dxccname, dxcc_entities.prefix as dxccprefix, station_cnty, station_cq, station_itu, station_active, eqslqthnickname, state, county, station_sig, station_sig_info, qrzrealtime, station_wwff, station_pota, oqrs, oqrs_text, oqrs_email, webadifrealtime, clublogrealtime, clublogignore, hrdlogrealtime, creation_date, last_modified
$sql = "select dxcc_entities.end, station_profile.station_id, station_profile_name, station_profile.hrdlog_username, station_gridsquare, station_city, station_iota, station_sota, station_callsign, station_power, station_dxcc, dxcc_entities.name as dxccname, dxcc_entities.prefix as dxccprefix, station_cnty, station_cq, station_itu, station_active, eqslqthnickname, state, county, station_sig, station_sig_info, qrzrealtime, station_wwff, station_pota, oqrs, oqrs_text, oqrs_email, webadifrealtime, clublogrealtime, clublogignore, hrdlogrealtime, creation_date, last_modified, station_uuid
from station_profile
join dxcc_entities on station_profile.station_dxcc = dxcc_entities.adif
where user_id = ?";
@@ -304,6 +304,11 @@ class Stationsetup_model extends CI_Model {
return 0;
} else {
// Insert new location
// Generate UUID if not provided
if (empty($dbdata['station_uuid'])) {
$dbdata['station_uuid'] = $this->db->query("SELECT UUID() as uuid")->row()->uuid;
}
$this->db->insert('station_profile', $dbdata);
$location_id = $this->db->insert_id();