diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php index 7d6a4344..76352f4e 100644 --- a/application/controllers/Eqsl.php +++ b/application/controllers/Eqsl.php @@ -11,7 +11,7 @@ class eqsl extends CI_Controller { $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'); } } - + private function loadFromFile($filepath) { ini_set('memory_limit', '-1'); @@ -94,6 +94,13 @@ class eqsl extends CI_Controller { } public function import() { + $this->load->model('stations'); + + if($this->stations->are_eqsl_nicks_defined() == 0) { + show_error('eQSL Nicknames in Station Profiles arent defined'); + exit; + } + ini_set('memory_limit', '-1'); set_time_limit(0); @@ -249,6 +256,11 @@ class eqsl extends CI_Controller { } // end function public function export() { + if($this->stations->are_eqsl_nicks_defined() == 0) { + show_error('eQSL Nicknames in Station Profiles arent defined'); + exit; + } + ini_set('memory_limit', '-1'); set_time_limit(0); $this->load->model('logbook_model'); diff --git a/application/models/Stations.php b/application/models/Stations.php index e5110a8e..044e80d6 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -30,8 +30,12 @@ class Stations extends CI_Model { return $this->db->get('station_profile'); } - + /* + * Function: add + * Adds post material into the station profile table. + */ function add() { + // Create data array with field values $data = array( 'station_profile_name' => xss_clean($this->input->post('station_profile_name', true)), 'station_gridsquare' => xss_clean(strtoupper($this->input->post('gridsquare', true))), @@ -49,6 +53,7 @@ class Stations extends CI_Model { 'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)), ); + // Insert Records $this->db->insert('station_profile', $data); } @@ -218,6 +223,20 @@ class Stations extends CI_Model { return $query; } + /* + * Function: are_eqsl_nicks_defined + * Description: Returns number of station profiles with eqslnicknames + */ + function are_eqsl_nicks_defined() { + $this->db->select('eqslqthnickname'); + $this->db->where('eqslqthnickname IS NOT NULL'); + $this->db->where('eqslqthnickname !=', ''); + $this->db->from('station_profile'); + $query = $this->db->get(); + + return $query->num_rows(); + } + } ?> \ No newline at end of file