diff --git a/application/controllers/Station.php b/application/controllers/Station.php index e59b44dd..3b332cc2 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -97,6 +97,16 @@ class Station extends CI_Controller { } } + // This function allows a user to claim ownership of a station location + function claim_user($id) { + // $id is the profile id + $this->load->model('stations'); + $this->stations->claim_user($id); + + //$this->stations->logbook_session_data(); + redirect('station'); + } + function reassign_profile($id) { // $id is the profile that needs reassigned to QSOs $this->load->model('stations'); diff --git a/application/models/Stations.php b/application/models/Stations.php index d179bb00..57ffe5fc 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -14,6 +14,8 @@ class Stations extends CI_Model { $this->db->from('station_profile'); $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left'); $this->db->group_by('station_profile.station_id'); + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); + $this->db->or_where('station_profile.user_id =', NULL); return $this->db->get(); } @@ -114,6 +116,16 @@ class Stations extends CI_Model { $this->db->delete($this->config->item('table_name')); } + function claim_user($id) { + + $data = array( + 'user_id' => $this->session->userdata('user_id') + ); + + $this->db->where('station_id', xss_clean($id, true)); + $this->db->update('station_profile', $data); + } + function set_active($current, $new) { // Clean inputs diff --git a/application/views/station_profile/index.php b/application/views/station_profile/index.php index b6b480dd..bececfee 100644 --- a/application/views/station_profile/index.php +++ b/application/views/station_profile/index.php @@ -75,6 +75,9 @@ qso_total;?> QSOs + user_id == "") { ?> + station_id; ?>" class="btn btn-outline-primary btn-sm"> Claim Ownership + station_id; ?>" class="btn btn-outline-primary btn-sm"> Edit