Skip to content

Commit

Permalink
'2.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbug authored Feb 20, 2024
2 parents 9a814e2 + 0c5a2ec commit a7c4750
Show file tree
Hide file tree
Showing 18 changed files with 1,016 additions and 395 deletions.
2 changes: 1 addition & 1 deletion application/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|
*/

$config['migration_version'] = 171;
$config['migration_version'] = 172;

/*
|--------------------------------------------------------------------------
Expand Down
70 changes: 47 additions & 23 deletions application/controllers/Dashboard.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller {
class Dashboard extends CI_Controller
{

public function index()
{
// If environment is set to development then show the debug toolbar
if(ENVIRONMENT == 'development') {
$this->output->enable_profiler(TRUE);
}
if (ENVIRONMENT == 'development') {
$this->output->enable_profiler(TRUE);
}

// Load language files
$this->lang->load('lotw');
Expand All @@ -19,13 +20,13 @@ public function index()
// LoTW infos
$this->load->model('LotwCert');

if($this->optionslib->get_option('version2_trigger') == "false") {
if ($this->optionslib->get_option('version2_trigger') == "false") {
redirect('welcome');
}

// Check if users logged in

if($this->user_model->validate_session() == 0) {
if ($this->user_model->validate_session() == 0) {
// user is not logged in
redirect('user/login');
}
Expand All @@ -34,19 +35,19 @@ public function index()
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));

// Calculate Lat/Lng from Locator to use on Maps
if($this->session->userdata('user_locator')) {
$this->load->library('qra');

$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
if ($qra_position) {
$data['qra'] = "set";
$data['qra_lat'] = $qra_position[0];
$data['qra_lng'] = $qra_position[1];
} else {
$data['qra'] = "none";
}
} else {
if ($this->session->userdata('user_locator')) {
$this->load->library('qra');

$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
if ($qra_position) {
$data['qra'] = "set";
$data['qra_lat'] = $qra_position[0];
$data['qra_lng'] = $qra_position[1];
} else {
$data['qra'] = "none";
}
} else {
$data['qra'] = "none";
}

$this->load->model('stations');
Expand All @@ -60,7 +61,7 @@ public function index()

$setup_required = false;

if($setup_required) {
if ($setup_required) {
$data['page_title'] = "Cloudlog Setup Checklist";

$this->load->view('interface_assets/header', $data);
Expand Down Expand Up @@ -88,7 +89,7 @@ public function index()
$data['total_countries_confirmed_eqsl'] = $CountriesBreakdown['Countries_Worked_EQSL'];
$data['total_countries_confirmed_lotw'] = $CountriesBreakdown['Countries_Worked_LOTW'];

$QSLStatsBreakdownArray =$this->logbook_model->get_QSLStats($logbooks_locations_array);
$QSLStatsBreakdownArray = $this->logbook_model->get_QSLStats($logbooks_locations_array);

$data['total_qsl_sent'] = $QSLStatsBreakdownArray['QSL_Sent'];
$data['total_qsl_rcvd'] = $QSLStatsBreakdownArray['QSL_Received'];
Expand Down Expand Up @@ -130,15 +131,38 @@ public function index()
$this->load->view('dashboard/index');
$this->load->view('interface_assets/footer');
}

}

function radio_display_component() {
function radio_display_component()
{
$this->load->model('cat');

$data['radio_status'] = $this->cat->recent_status();
$this->load->view('components/radio_display_table', $data);
}

function upcoming_dxcc_component()
{

$this->load->model('Workabledxcc_model');

$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));

// Get the user ID from the session data
$userID = $this->session->userdata('user_id');


$thisWeekRecords = $this->Workabledxcc_model->GetThisWeek();


$data['thisWeekRecords'] = $thisWeekRecords;

usort($data['thisWeekRecords'], function ($a, $b) {
$dateA = new DateTime($a['1']);
$dateB = new DateTime($b['1']);
return $dateA <=> $dateB;
});

$this->load->view('components/upcoming_dxccs', $data);
}
}
170 changes: 170 additions & 0 deletions application/controllers/Workabledxcc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/*
Controller to interact with the Cloudlog DXPed Aggregator
*/

class Workabledxcc extends CI_Controller
{

function __construct()
{
parent::__construct();

$this->load->model('user_model');
if (!$this->user_model->authorize(2)) {
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
redirect('dashboard');
}
}

public function index()
{
// Load public view
$data['page_title'] = "Upcoming DXPeditions";
$this->load->view('interface_assets/header', $data);
$this->load->view('/workabledxcc/index');
$this->load->view('interface_assets/footer');
}

public function dxcclist()
{

$json = file_get_contents('https://cdn.cloudlog.org/read_ng3k_dxped_list.php');

// Decode the JSON data into a PHP array
$dataResult = json_decode($json, true);

// Initialize an empty array to store the required data
$requiredData = array();

// Get Date format
if ($this->session->userdata('user_date_format')) {
// If Logged in and session exists
$custom_date_format = $this->session->userdata('user_date_format');
} else {
// Get Default date format from /config/cloudlog.php
$custom_date_format = $this->config->item('qso_date_format');
}

// Iterate through the decoded JSON data
foreach ($dataResult as $item) {
// Create a new array with the required fields and add it to the main array
$oldStartDate = DateTime::createFromFormat('Y-m-d', $item['0']);

$StartDate = $oldStartDate->format($custom_date_format);

$oldEndDate = DateTime::createFromFormat('Y-m-d', $item['1']);

$EndDate = $oldEndDate->format($custom_date_format);

$this->load->model('logbook_model');
$dxccInfo = $this->logbook_model->dxcc_lookup($item['callsign'], $StartDate);

// Call DXCC Worked function to check if the DXCC has been worked before
if (isset($dxccInfo['entity'])) {
$dxccWorked = $this->dxccWorked($dxccInfo['entity']);
} else {
// Handle the case where 'entity' is not set in $dxccInfo
$dxccWorked = array(
'workedBefore' => false,
'confirmed' => false,
);
}

$requiredData[] = array(
'clean_date' => $item['0'],
'start_date' => $StartDate,
'end_date' => $EndDate,
'country' => $item['2'],
'notes' => $item['6'],
'callsign' => $item['callsign'],
'workedBefore' => $dxccWorked['workedBefore'],
'confirmed' => $dxccWorked['confirmed'],
);
}

$data['dxcclist'] = $requiredData;

// Return the array with the required data

$this->load->view('/workabledxcc/components/dxcclist', $data);
}

function dxccWorked($country)
{

$return = [
"workedBefore" => false,
"confirmed" => false,
];

$user_default_confirmation = $this->session->userdata('user_default_confirmation');
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$this->load->model('logbook_model');

if (!empty($logbooks_locations_array)) {
$this->db->where('COL_PROP_MODE !=', 'SAT');

$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_COUNTRY', urldecode($country));

$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow) {
$return['workedBefore'] = true;
}

$extrawhere = '';
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
$extrawhere = "COL_QSL_RCVD='Y'";
}
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) {
if ($extrawhere != '') {
$extrawhere .= " OR";
}
$extrawhere .= " COL_LOTW_QSL_RCVD='Y'";
}
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) {
if ($extrawhere != '') {
$extrawhere .= " OR";
}
$extrawhere .= " COL_EQSL_QSL_RCVD='Y'";
}

if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) {
if ($extrawhere != '') {
$extrawhere .= " OR";
}
$extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'";
}


$this->load->model('logbook_model');
$this->db->where('COL_PROP_MODE !=', 'SAT');
if ($extrawhere != '') {
$this->db->where('(' . $extrawhere . ')');
} else {
$this->db->where("1=0");
}


$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_COUNTRY', urldecode($country));

$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow) {
$return['confirmed'] = true;
}

return $return;
} else {
$return['workedBefore'] = false;
$return['confirmed'] = false;


return $return;;
}
}

}
6 changes: 5 additions & 1 deletion application/libraries/DxccFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ class DxccFlag

public function get($dxcc)
{
return $this->dxccFlags[$dxcc];
if (!isset($this->dxccFlags[$dxcc])) {
return null;
} else {
return $this->dxccFlags[$dxcc];
}
}
}
30 changes: 30 additions & 0 deletions application/migrations/172_tag_2_6_5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

/*
* Tag Cloudlog as 2.6.5
*/

class Migration_tag_2_6_5 extends CI_Migration {

public function up()
{

// Tag Cloudlog 2.6.3
$this->db->where('option_name', 'version');
$this->db->update('options', array('option_value' => '2.6.5'));

// Trigger Version Info Dialog
$this->db->where('option_type', 'version_dialog');
$this->db->where('option_name', 'confirmed');
$this->db->update('user_options', array('option_value' => 'false'));

}

public function down()
{
$this->db->where('option_name', 'version');
$this->db->update('options', array('option_value' => '2.6.4'));
}
}
Loading

0 comments on commit a7c4750

Please sign in to comment.