mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
UUID for locations / export / import / create
This commit is contained in:
@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
||||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 262;
|
||||
$config['migration_version'] = 263;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -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'),
|
||||
];
|
||||
|
||||
|
||||
24
application/migrations/263_add_station_uuid.php
Normal file
24
application/migrations/263_add_station_uuid.php
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 //
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user