Removed some unused files and refactored some functions

This commit is contained in:
Andreas Kristiansen
2024-04-23 13:34:30 +02:00
parent 42a5c95caf
commit afbf1713c9
6 changed files with 27 additions and 190 deletions

View File

@@ -18,23 +18,23 @@ class Debug extends CI_Controller
public function index() {
$this->load->helper('file');
$this->load->model('MigrationVersion');
$this->load->model('Logbook_model');
$this->load->model('Debug_model');
$this->load->model('Stations');
$footerData = [];
$footerData['scripts'] = ['assets/js/sections/debug.js'];
$data['stations'] = $this->Stations->all();
$data['qso_total'] = $this->Logbook_model->count_all_qso();
$data['qso_total'] = $this->Debug_model->count_all_qso();
$data['qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
if ($data['qsos_with_no_station_id']) {
$data['calls_wo_sid'] = $this->Logbook_model->calls_without_station_id();
}
$data['migration_version'] = $this->MigrationVersion->getMigrationVersion();
$data['migration_version'] = $this->Debug_model->getMigrationVersion();
// Test writing to backup folder
$backup_folder = $this->permissions->is_really_writable('backup');
@@ -152,7 +152,7 @@ class Debug extends CI_Controller
return;
}
public function selfupdate() {
public function selfupdate() {
if (file_exists('.git')) {
try {
$st=exec('touch '.realpath(APPPATH.'../').'/.maintenance');

View File

@@ -1,18 +0,0 @@
<?php
class Thirdpartylogins 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() {
}
}
?>

View File

@@ -55,7 +55,7 @@ class Debug_model extends CI_Model
$user_id = $get_user_id;
} else {
$user_id = 'not_assigned';
}
}
} else {
$user_id = 'not_assigned';
}
@@ -74,7 +74,7 @@ class Debug_model extends CI_Model
}
// ***** QSL Cards ***** //
// Let's scan the whole folder and get necessary data for each file
foreach (scandir($this->src_qsl) as $file) {
// Ignore files if they are not jpg, png or gif
@@ -153,4 +153,24 @@ class Debug_model extends CI_Model
$row = $result->row();
return $row->qsoid;
}
// Returns the number of qso's total on this instance
function count_all_qso() {
$sql = 'SELECT COUNT(*) AS total FROM '. $this->config->item('table_name').' WHERE station_id IS NOT NULL;';
$query = $this->db->query($sql);
return $query->row()->total;
}
function getMigrationVersion() {
$this->db->select_max('version');
$query = $this->db->get('migrations');
$migration_version = $query->row();
if ($query->num_rows() == 1) {
$migration_version = $query->row()->version;
return $migration_version;
} else {
return null;
}
}
}

View File

@@ -1777,13 +1777,6 @@ class Logbook_model extends CI_Model {
}
}
// returns the number of qso's total on this instance
function count_all_qso() {
$sql = 'SELECT COUNT(*) AS total FROM '. $this->config->item('table_name').' WHERE station_id IS NOT NULL;';
$query = $this->db->query($sql);
return $query->row()->total;
}
/*
* Function returns the QSOs from the logbook, which have not been either marked as uploaded to hrdlog, or has been modified with an edit
*/

View File

@@ -1,20 +0,0 @@
<?php
class MigrationVersion extends CI_Model {
function getMigrationVersion() {
$this->db->select_max('version');
$query = $this->db->get('migrations');
$migration_version = $query->row();
if ($query->num_rows() == 1) {
$migration_version = $query->row()->version;
return $migration_version;
} else {
return null;
}
}
}
?>

View File

@@ -1,138 +0,0 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Thirdpartylogin extends CI_Model {
public $table = 'thirdparty_logins';
// Get Thirdparty Login from DB
public function details($service_id) {
$this->db->where('service_id', $service_id);
$query = $this->db->get($this->table);
if (!$query->row()) {
// Array Empty
return false;
} else {
// Array Not Empty
$data = array(
'service_id' => $query->row()->service_id,
'user_id' => $query->row()->user_id,
'service_name' => $query->row()->service_name,
'service_username' => $this->encryption->decrypt($query->row()->service_username),
'service_password' => $this->encryption->decrypt($query->row()->service_password),
'active' => $query->row()->active,
);
return $data;
}
}
// Save Thirdparty Login to DB
function save($dataentry) {
// Save user's third party login credentials
$data = array(
'user_id' => $dataentry['user_id'],
'service_name' => $dataentry['service_name'],
'service_username' => $dataentry['service_username'],
'service_password' => $dataentry['service_password'],
'active' => 1,
'modified' => date('Y-m-d H:i:s')
);
if($this->db->insert($this->table, $data)) {
return true;
} else {
log_message('error', 'Failed to save third party login.');
return false;
}
}
// Update Thirdparty Login to DB
function update($dataentry) {
// Save user's third party login credentials
$data = array(
'service_name' => $dataentry['service_name'],
'service_username' => $dataentry['service_username'],
'service_password' => $dataentry['service_password'],
'modified' => date('Y-m-d H:i:s')
);
$this->db->where('service_id', $dataentry['service_id']);
if($this->db->update($this->table, $data)) {
return true;
} else {
log_message('error', 'Updated '.$dataentry['service_id'].' third party login.');
return false;
}
}
// Delete Thirdparty Login from DB
function delete($service_id) {
// Delete third party login
$this->db->where('service_id', $service_id);
if($this->db->delete($this->table)) {
return true;
} else {
log_message('error', 'Deleted '.$service_id.' third party login.');
return false;
}
}
// Activate Thirdparty Login
function activate($service_id) {
// Activate third party login
$data = array(
'active' => 1,
'modified' => date('Y-m-d H:i:s')
);
$this->db->where('service_id', $service_id);
if($this->db->update($this->table, $data)) {
return true;
} else {
log_message('error', 'Unable to activate '.$service_id.' third party login.');
return false;
}
}
// Deactivate Thirdparty Login
function deactivate($service_id) {
// Deactivate third party login
$data = array(
'active' => 0,
'modified' => date('Y-m-d H:i:s')
);
$this->db->where('service_id', $service_id);
if($this->db->update($this->table, $data)) {
return true;
} else {
log_message('error', 'Deactivate '.$service_id.' third party login.');
return false;
}
}
// List all third party logins for a user
function list_all($user_id) {
$this->db->where('user_id', $user_id);
$query = $this->db->get($this->table);
if (!$query->row()) {
// Array Empty
return false;
} else {
// Array Not Empty
$data = array();
foreach ($query->result() as $row) {
$data[] = array(
'service_id' => $row->service_id,
'service_name' => $row->service_name,
'service_username' => $this->encryption->decrypt($row->service_username),
'active' => $row->active,
);
}
return $data;
}
}
}
?>