diff --git a/application/controllers/Debug.php b/application/controllers/Debug.php index 97e24a274..c236b42d2 100644 --- a/application/controllers/Debug.php +++ b/application/controllers/Debug.php @@ -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'); diff --git a/application/controllers/Thirdpartylogins.php b/application/controllers/Thirdpartylogins.php deleted file mode 100644 index 0c1bc49a2..000000000 --- a/application/controllers/Thirdpartylogins.php +++ /dev/null @@ -1,18 +0,0 @@ -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() { - - } -} - -?> \ No newline at end of file diff --git a/application/models/Debug_model.php b/application/models/Debug_model.php index 1253543b0..f29b3c451 100644 --- a/application/models/Debug_model.php +++ b/application/models/Debug_model.php @@ -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; + } + } } diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 4e2d5ebe5..7311bd3e2 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -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 */ diff --git a/application/models/MigrationVersion.php b/application/models/MigrationVersion.php deleted file mode 100644 index bec7d47ab..000000000 --- a/application/models/MigrationVersion.php +++ /dev/null @@ -1,20 +0,0 @@ -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; - } - } - -} - -?> diff --git a/application/models/Thirdpartylogin.php b/application/models/Thirdpartylogin.php deleted file mode 100644 index 510d30c3f..000000000 --- a/application/models/Thirdpartylogin.php +++ /dev/null @@ -1,138 +0,0 @@ -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; - } - } -} -?> \ No newline at end of file