Skip to content

Commit

Permalink
Make auto QTH function configurable on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
phl0 committed Oct 19, 2022
1 parent e67435d commit ebe05ae
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 28 deletions.
16 changes: 0 additions & 16 deletions application/config/cloudlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,3 @@
*/

$config['map_6digit_grids'] = FALSE;


/*
|--------------------------------------------------------------------------
| Automatically populate the QTH
|--------------------------------------------------------------------------
|
| Setting this to TRUE allows the QTH locator to be pre-filled
| based on the person's location when creating new QSO.
| OSM's Nominatim API is being used for that purpose
|
| Default is: FALSE
|
*/

$config['qso_auto_qth'] = FALSE;
2 changes: 1 addition & 1 deletion application/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 103;
$config['migration_version'] = 104;

/*
|--------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions application/controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function add() {
$data['user_timezone'] = $this->input->post('user_timezone');
$data['user_measurement_base'] = $this->input->post('user_measurement_base');
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup');
$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');
Expand Down Expand Up @@ -96,6 +97,7 @@ function add() {
$this->input->post('user_measurement_base'),
$this->input->post('user_date_format'),
$this->input->post('user_stylesheet'),
$this->input->post('user_qth_lookup'),
$this->input->post('user_sota_lookup'),
$this->input->post('user_wwff_lookup'),
$this->input->post('user_show_notes'),
Expand Down Expand Up @@ -134,6 +136,7 @@ function add() {
$data['user_locator'] = $this->input->post('user_locator');
$data['user_measurement_base'] = $this->input->post('user_measurement_base');
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup');
$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');
Expand Down Expand Up @@ -302,6 +305,12 @@ function edit() {
$data['user_stylesheet'] = $q->user_stylesheet;
}

if($this->input->post('user_qth_lookup')) {
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup', true);
} else {
$data['user_qth_lookup'] = $q->user_qth_lookup;
}

if($this->input->post('user_sota_lookup')) {
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup', true);
} else {
Expand Down Expand Up @@ -397,6 +406,7 @@ function edit() {
$data['user_locator'] = $this->input->post('user_locator', true);
$data['user_timezone'] = $this->input->post('user_timezone', true);
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup');
$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');
Expand Down
29 changes: 29 additions & 0 deletions application/migrations/104_user_auto_qth_option.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

/*
* This adds an option to enable grid and name lookup
* for WWFF references
*/

class Migration_user_auto_qth_option extends CI_Migration {

public function up()
{
if (!$this->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');
}
}
}
8 changes: 6 additions & 2 deletions application/models/User_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ function exists_by_email($email) {
// 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_wwff_lookup, $user_show_notes,
$user_column1, $user_column2, $user_column3, $user_column4, $user_column5, $user_show_profile_image) {
$measurement, $user_date_format, $user_stylesheet, $user_qth_lookup, $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)) {
$data = array(
Expand All @@ -129,6 +130,7 @@ function add($username, $password, $email, $type, $firstname, $lastname, $callsi
'user_measurement_base' => xss_clean($measurement),
'user_date_format' => xss_clean($user_date_format),
'user_stylesheet' => xss_clean($user_stylesheet),
'user_qth_lookup' => xss_clean($user_qth_lookup),
'user_sota_lookup' => xss_clean($user_sota_lookup),
'user_wwff_lookup' => xss_clean($user_wwff_lookup),
'user_show_notes' => xss_clean($user_show_notes),
Expand Down Expand Up @@ -181,6 +183,7 @@ function edit($fields) {
'user_measurement_base' => xss_clean($fields['user_measurement_base']),
'user_date_format' => xss_clean($fields['user_date_format']),
'user_stylesheet' => xss_clean($fields['user_stylesheet']),
'user_qth_lookup' => xss_clean($fields['user_qth_lookup']),
'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']),
Expand Down Expand Up @@ -297,6 +300,7 @@ function update_session($id) {
'user_measurement_base' => $u->row()->user_measurement_base,
'user_date_format' => $u->row()->user_date_format,
'user_stylesheet' => $u->row()->user_stylesheet,
'user_qth_lookup' => isset($u->row()->user_qth_lookup) ? $u->row()->user_qth_lookup : 0,
'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,
Expand Down
2 changes: 1 addition & 1 deletion application/views/interface_assets/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ function searchButtonPress(){
});
<?php } ?>

<?php if ($this->config->item('qso_auto_qth')) { ?>
<?php if ($this->session->userdata('user_qth_lookup') == 1) { ?>
$('#qth').focusout(function() {
if ($('#locator').val() === '') {
var lat = 0;
Expand Down
17 changes: 13 additions & 4 deletions application/views/user/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,31 @@
</div>

<div class="form-row">
<div class="form-group col-md-6">
<div class="form-group col-md-4">
<label for="qthlookup">Location auto lookup.</label>
<select class="custom-select" id="qthlookup" name="user_qth_lookup">
<option value="0"><?php echo $this->lang->line('general_word_no'); ?></option>
<option value="1"><?php echo $this->lang->line('general_word_yes'); ?></option>
</select>
<div class="small form-text text-muted">If set, gridsquare is fetched based on location name.</div></td>
</div>

<div class="form-group col-md-4">
<label for="sotalookup">SOTA auto lookup gridsquare and name for summit.</label>
<select class="custom-select" id="sotalookup" name="user_sota_lookup">
<option value="0"><?php echo $this->lang->line('general_word_no'); ?></option>
<option value="1"><?php echo $this->lang->line('general_word_yes'); ?></option>
</select>
<div class="small form-text text-muted">If this is set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
<div class="small form-text text-muted">If set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
</div>

<div class="form-group col-md-6">
<div class="form-group col-md-4">
<label for="wwfflookup">WWFF auto lookup gridsquare and name for reference.</label>
<select class="custom-select" id="wwfflookup" name="user_wwff_lookup">
<option value="0"><?php echo $this->lang->line('general_word_no'); ?></option>
<option value="1"><?php echo $this->lang->line('general_word_yes'); ?></option>
</select>
<div class="small form-text text-muted">If this is set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
<div class="small form-text text-muted">If set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
</div>
</div>

Expand Down
16 changes: 12 additions & 4 deletions application/views/user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,29 @@
</div>
<div class="card-body">
<div class="form-row">
<div class="form-group col-md-6">
<div class="form-group col-md-4">
<label for="qthlookup"> Location auto lookup.</label>
<select class="custom-select" id="qthlookup" name="user_qth_lookup">
<option value="1" <?php if ($user_qth_lookup == 1) { echo " selected =\"selected\""; } ?>><?php echo $this->lang->line('general_word_yes'); ?></option>
<option value="0" <?php if ($user_qth_lookup == 0) { echo " selected =\"selected\""; } ?>><?php echo $this->lang->line('general_word_no'); ?></option>
</select>
<div class="small form-text text-muted">If set, gridsquare is fetched based on location name.</div></td>
</div>
<div class="form-group col-md-4">
<label for="sotalookup">SOTA auto lookup gridsquare and name for summit.</label>
<select class="custom-select" id="sotalookup" name="user_sota_lookup">
<option value="1" <?php if ($user_sota_lookup == 1) { echo " selected =\"selected\""; } ?>><?php echo $this->lang->line('general_word_yes'); ?></option>
<option value="0" <?php if ($user_sota_lookup == 0) { echo " selected =\"selected\""; } ?>><?php echo $this->lang->line('general_word_no'); ?></option>
</select>
<div class="small form-text text-muted">If this is set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
<div class="small form-text text-muted">If set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
</div>
<div class="form-group col-md-6">
<div class="form-group col-md-4">
<label for="wwfflookup">WWFF auto lookup gridsquare and name for summit.</label>
<select class="custom-select" id="wwfflookup" name="user_wwff_lookup">
<option value="1" <?php if ($user_wwff_lookup == 1) { echo " selected =\"selected\""; } ?>><?php echo $this->lang->line('general_word_yes'); ?></option>
<option value="0" <?php if ($user_wwff_lookup == 0) { echo " selected =\"selected\""; } ?>><?php echo $this->lang->line('general_word_no'); ?></option>
</select>
<div class="small form-text text-muted">If this is set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
<div class="small form-text text-muted">If set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
</div>
</div>
</div>
Expand Down

0 comments on commit ebe05ae

Please sign in to comment.