diff --git a/application/config/migration.php b/application/config/migration.php index 7ccd0b37..aa4f71e3 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 102; +$config['migration_version'] = 103; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 6652b5f7..9301bedc 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -436,14 +436,23 @@ class QSO extends CI_Controller { echo json_encode($json); } - public function get_sota_info() { - $this->load->library('sota'); + public function get_sota_info() { + $this->load->library('sota'); - $sota = xss_clean($this->input->post('sota')); + $sota = xss_clean($this->input->post('sota')); - header('Content-Type: application/json'); - echo $this->sota->info($sota); - } + header('Content-Type: application/json'); + echo $this->sota->info($sota); + } + + public function get_wwff_info() { + $this->load->library('wwff'); + + $wwff = xss_clean($this->input->post('wwff')); + + header('Content-Type: application/json'); + echo $this->wwff->info($wwff); + } function check_locator($grid) { $grid = $this->input->post('locator'); diff --git a/application/controllers/User.php b/application/controllers/User.php index 7ce64d61..c3a5c41d 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -68,6 +68,7 @@ class User extends CI_Controller { $data['user_measurement_base'] = $this->input->post('user_measurement_base'); $data['user_stylesheet'] = $this->input->post('user_stylesheet'); $data['user_sota_lookup'] = $this->input->post('user_sota_lookup'); + $data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup'); $data['user_show_notes'] = $this->input->post('user_show_notes'); $data['user_column1'] = $this->input->post('user_column1'); $data['user_column2'] = $this->input->post('user_column2'); @@ -96,6 +97,7 @@ class User extends CI_Controller { $this->input->post('user_date_format'), $this->input->post('user_stylesheet'), $this->input->post('user_sota_lookup'), + $this->input->post('user_wwff_lookup'), $this->input->post('user_show_notes'), $this->input->post('user_column1'), $this->input->post('user_column2'), @@ -133,6 +135,7 @@ class User extends CI_Controller { $data['user_measurement_base'] = $this->input->post('user_measurement_base'); $data['user_stylesheet'] = $this->input->post('user_stylesheet'); $data['user_sota_lookup'] = $this->input->post('user_sota_lookup'); + $data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup'); $data['user_show_notes'] = $this->input->post('user_show_notes'); $data['user_column1'] = $this->input->post('user_column1'); $data['user_column2'] = $this->input->post('user_column2'); @@ -305,6 +308,12 @@ class User extends CI_Controller { $data['user_sota_lookup'] = $q->user_sota_lookup; } + if($this->input->post('user_wwff_lookup')) { + $data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup', true); + } else { + $data['user_wwff_lookup'] = $q->user_wwff_lookup; + } + if($this->input->post('user_show_notes')) { $data['user_show_notes'] = $this->input->post('user_show_notes', true); } else { @@ -389,6 +398,7 @@ class User extends CI_Controller { $data['user_timezone'] = $this->input->post('user_timezone', true); $data['user_stylesheet'] = $this->input->post('user_stylesheet'); $data['user_sota_lookup'] = $this->input->post('user_sota_lookup'); + $data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup'); $data['user_show_notes'] = $this->input->post('user_show_notes'); $data['user_column1'] = $this->input->post('user_column1'); $data['user_column2'] = $this->input->post('user_column2'); diff --git a/application/libraries/Wwff.php b/application/libraries/Wwff.php new file mode 100644 index 00000000..f6d036ea --- /dev/null +++ b/application/libraries/Wwff.php @@ -0,0 +1,59 @@ + $value]; + } + } + } + + return $json; + } + + // fetches the summit information from WWFF + public function info($ref) { + $url = 'https://www.cqgma.org/wwff_ref.php?ref='.$ref; + + // Let's use cURL instead of file_get_contents + // begin script + $ch = curl_init(); + + // basic curl options for all requests + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + + // use the URL we built + curl_setopt($ch, CURLOPT_URL, $url); + + $summit_info = curl_exec($ch); + + // Close cURL handle + curl_close($ch); + + return $summit_info; + } +} diff --git a/application/migrations/103_add_user_wwff_lookup.php b/application/migrations/103_add_user_wwff_lookup.php new file mode 100644 index 00000000..0c8ee72e --- /dev/null +++ b/application/migrations/103_add_user_wwff_lookup.php @@ -0,0 +1,29 @@ +db->field_exists('user_wwff_lookup', 'users')) { + $fields = array( + 'user_wwff_lookup integer DEFAULT 0 AFTER user_sota_lookup', + ); + + $this->dbforge->add_column('users', $fields); + } + } + + public function down() + { + if ($this->db->field_exists('user_wwff_lookup', 'users')) { + $this->dbforge->drop_column('users', 'user_wwff_lookup'); + } + } +} diff --git a/application/models/User_model.php b/application/models/User_model.php index 2292ed0b..cc61d322 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -112,7 +112,7 @@ class User_Model extends CI_Model { // FUNCTION: bool add($username, $password, $email, $type) // Add a user function add($username, $password, $email, $type, $firstname, $lastname, $callsign, $locator, $timezone, - $measurement, $user_date_format, $user_stylesheet, $user_sota_lookup, $user_show_notes, + $measurement, $user_date_format, $user_stylesheet, $user_sota_lookup, $user_wwff_lookup, $user_show_notes, $user_column1, $user_column2, $user_column3, $user_column4, $user_column5, $user_show_profile_image) { // Check that the user isn't already used if(!$this->exists($username)) { @@ -130,6 +130,7 @@ class User_Model extends CI_Model { 'user_date_format' => xss_clean($user_date_format), 'user_stylesheet' => xss_clean($user_stylesheet), 'user_sota_lookup' => xss_clean($user_sota_lookup), + 'user_wwff_lookup' => xss_clean($user_wwff_lookup), 'user_show_notes' => xss_clean($user_show_notes), 'user_column1' => xss_clean($user_column1), 'user_column2' => xss_clean($user_column2), @@ -181,6 +182,7 @@ class User_Model extends CI_Model { 'user_date_format' => xss_clean($fields['user_date_format']), 'user_stylesheet' => xss_clean($fields['user_stylesheet']), 'user_sota_lookup' => xss_clean($fields['user_sota_lookup']), + 'user_wwff_lookup' => xss_clean($fields['user_wwff_lookup']), 'user_show_notes' => xss_clean($fields['user_show_notes']), 'user_column1' => xss_clean($fields['user_column1']), 'user_column2' => xss_clean($fields['user_column2']), @@ -296,6 +298,7 @@ class User_Model extends CI_Model { 'user_date_format' => $u->row()->user_date_format, 'user_stylesheet' => $u->row()->user_stylesheet, 'user_sota_lookup' => isset($u->row()->user_sota_lookup) ? $u->row()->user_sota_lookup : 0, + 'user_wwff_lookup' => isset($u->row()->user_wwff_lookup) ? $u->row()->user_wwff_lookup : 0, 'user_show_notes' => isset($u->row()->user_show_notes) ? $u->row()->user_show_notes : 1, 'user_show_profile_image' => isset($u->row()->user_show_profile_image) ? $u->row()->user_show_profile_image : 0, 'user_column1' => isset($u->row()->user_column1) ? $u->row()->user_column1: 'Mode', diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index bc72391f..65c53d5f 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1088,6 +1088,27 @@ $(document).on('keypress',function(e) { }); +session->userdata('user_wwff_lookup') == 1) { ?> + $('#wwff_ref').change(function() { + var wwff = $('#wwff_ref').val(); + if (wwff.length > 0) { + $.ajax({ + url: base_url+'index.php/qso/get_wwff_info', + type: 'post', + data: {'wwff': wwff}, + success: function(res) { + $('#qth').val(res.name); + $('#locator').val(res.locator); + }, + error: function() { + $('#qth').val(''); + $('#locator').val(''); + }, + }); + } + }); + + config->item('qso_auto_qth')) { ?> $('#qth').focusout(function() { if ($('#locator').val() === '') { diff --git a/application/views/user/add.php b/application/views/user/add.php index adc6c5db..209e4188 100644 --- a/application/views/user/add.php +++ b/application/views/user/add.php @@ -129,13 +129,24 @@ -
- - -
If this is set, name and gridsquare is fetched from the API and filled in location and locator.
+
+
+ + +
If this is set, name and gridsquare is fetched from the API and filled in location and locator.
+
+ +
+ + +
If this is set, name and gridsquare is fetched from the API and filled in location and locator.
+
diff --git a/application/views/user/edit.php b/application/views/user/edit.php index ad20e890..1e34a254 100644 --- a/application/views/user/edit.php +++ b/application/views/user/edit.php @@ -278,27 +278,35 @@

-
- Summits On The Air + Gridsquare and Location Autocomplete
-
- - -
If this is set, name and gridsquare is fetched from the API and filled in location and locator.
+
+
+ + +
If this is set, name and gridsquare is fetched from the API and filled in location and locator.
+
+
+ + +
If this is set, name and gridsquare is fetched from the API and filled in location and locator.
+
-
-
+