Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADIF Import] Added option to always use login call as operator. #1013

Merged
merged 1 commit into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/controllers/Adif.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function import() {


$custom_errors .= $this->logbook_model->import($record, $this->input->post('station_profile'),
$this->input->post('skipDuplicate'), $this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), true);
$this->input->post('skipDuplicate'), $this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), true, $this->input->post('operatorName'));

};

Expand Down
8 changes: 4 additions & 4 deletions application/controllers/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function help()

function edit($key) {
$this->load->model('user_model');

if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }

$this->load->model('api_model');
Expand Down Expand Up @@ -426,12 +426,12 @@ function qso() {
{
break;
};


if(isset($obj['station_profile_id'])) {
$this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, false);
$this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, false, false);
} else {
$this->logbook_model->import($record, 0, NULL, NULL, NULL, NULL, false);
$this->logbook_model->import($record, 0, NULL, NULL, NULL, NULL, false, false);
}

};
Expand Down
68 changes: 34 additions & 34 deletions application/controllers/Lotw.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Lotw extends CI_Controller {
|--------------------------------------------------------------------------
| Controller: Lotw
|--------------------------------------------------------------------------
|
|
| This Controller handles all things LOTW, upload and download.
|
|
Expand All @@ -23,7 +23,7 @@ function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));

// Load language files
$this->lang->load('lotw');
}
Expand All @@ -32,7 +32,7 @@ function __construct()
|--------------------------------------------------------------------------
| Function: index
|--------------------------------------------------------------------------
|
|
| Default function for the controller which loads when doing /lotw
| this shows all the uploaded lotw p12 certificates the user has uploaded
|
Expand Down Expand Up @@ -65,7 +65,7 @@ public function index() {
|--------------------------------------------------------------------------
| Function: cert_upload
|--------------------------------------------------------------------------
|
|
| Nothing fancy just shows the cert_upload form for uploading p12 files
|
*/
Expand All @@ -83,14 +83,14 @@ public function cert_upload() {
// Load Views
$this->load->view('interface_assets/header', $data);
$this->load->view('lotw_views/upload_cert', array('error' => ' ' ));
$this->load->view('interface_assets/footer');
$this->load->view('interface_assets/footer');
}

/*
|--------------------------------------------------------------------------
| Function: do_cert_upload
|--------------------------------------------------------------------------
|
|
| do_cert_upload is called from cert_upload form submit and handles uploading
| and processing of p12 files and storing the data into mysql
|
Expand Down Expand Up @@ -127,7 +127,7 @@ public function do_cert_upload()
// Load Views
$this->load->view('interface_assets/header', $data);
$this->load->view('lotw_views/upload_cert', $error);
$this->load->view('interface_assets/footer');
$this->load->view('interface_assets/footer');
}
else
{
Expand All @@ -141,10 +141,10 @@ public function do_cert_upload()

// Check DXCC & Store Country Name
$this->load->model('Logbook_model');

if($this->input->post('dxcc') != "") {
$dxcc = $this->input->post('dxcc');
} else{
} else{
$dxcc_check = $this->Logbook_model->check_dxcc_table($info['issued_callsign'], $info['validFrom']);
$dxcc = $dxcc_check[1];
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public function do_cert_upload()
|--------------------------------------------------------------------------
| Function: lotw_upload
|--------------------------------------------------------------------------
|
|
| This function Uploads to LOTW
|
*/
Expand Down Expand Up @@ -242,9 +242,9 @@ public function lotw_upload() {
if(empty($data['qsos']->result())){
echo $station_profile->station_callsign." (".$station_profile->station_profile_name.") No QSOs to Upload <br>";
continue;
}
}

foreach ($data['qsos']->result() as $temp_qso) {
foreach ($data['qsos']->result() as $temp_qso) {
array_push($qso_id_array, $temp_qso->COL_PRIMARY_KEY);
}

Expand All @@ -266,25 +266,25 @@ public function lotw_upload() {

//The URL that accepts the file upload.
$url = 'https://lotw.arrl.org/lotw/upload';

//The name of the field for the uploaded file.
$uploadFieldName = 'upfile';

//The full path to the file that you want to upload
$filePath = realpath($filename_for_saving);

//Initiate cURL
$ch = curl_init();

//Set the URL
curl_setopt($ch, CURLOPT_URL, $url);

//Set the HTTP request to POST
curl_setopt($ch, CURLOPT_POST, true);

//Tell cURL to return the output as a string.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//If the function curl_file_create exists
if(function_exists('curl_file_create')){
//Use the recommended way, creating a CURLFile object.
Expand All @@ -298,23 +298,23 @@ public function lotw_upload() {
//starting with an @
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
}

//Setup our POST fields
$postFields = array(
$uploadFieldName => $filePath
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

//Execute the request
$result = curl_exec($ch);

//If an error occured, throw an exception
//with the error message.
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}

$pos = strpos($result, "<!-- .UPL. accepted -->");

if ($pos === false) {
Expand Down Expand Up @@ -353,7 +353,7 @@ public function lotw_upload() {
|--------------------------------------------------------------------------
| Function: delete_cert
|--------------------------------------------------------------------------
|
|
| Deletes LOTW certificate from the MySQL table
|
*/
Expand All @@ -375,7 +375,7 @@ public function delete_cert($cert_id) {
|--------------------------------------------------------------------------
| Function: decrypt_key
|--------------------------------------------------------------------------
|
|
| Accepts p12 file and optional password and encrypts the file returning
| the required fields for LOTW and the PEM Key
|
Expand Down Expand Up @@ -429,12 +429,12 @@ public function decrypt_key($file, $password = "") {

return $data;
}

/*
|--------------------------------------------------------------------------
| Function: loadFromFile
|--------------------------------------------------------------------------
|
|
| $filepath is the ADIF file, $display_view is used to hide the output if its internal script
|
| Internal function that takes the LoTW ADIF and imports into the log
Expand Down Expand Up @@ -498,7 +498,7 @@ private function loadFromFile($filepath, $display_view = "TRUE")
$station_id = $this->logbook_model->find_correct_station_id($record['station_callsign'], $record['my_gridsquare']);

if ($station_id != NULL) {
$result = $this->logbook_model->import($record, $station_id, NULL, TRUE, NULL, NULL, true); // Create the Entry
$result = $this->logbook_model->import($record, $station_id, NULL, TRUE, NULL, NULL, true, false); // Create the Entry
if ($result == "") {
$lotw_status = 'QSO imported';
} else {
Expand Down Expand Up @@ -557,8 +557,8 @@ private function loadFromFile($filepath, $display_view = "TRUE")
|--------------------------------------------------------------------------
| Function: lotw_download
|--------------------------------------------------------------------------
|
| Collects users with LoTW usernames and passwords and runs through them
|
| Collects users with LoTW usernames and passwords and runs through them
| downloading matching QSOs.
|
*/
Expand Down Expand Up @@ -834,11 +834,11 @@ public function export() {

/*
Load the ARRL LOTW User Activity CSV and saves into uploads/lotw_users.csv
*/
*/
public function load_users() {
$contents = file_get_contents('https://lotw.arrl.org/lotw-user-activity.csv', true);

if($contents === FALSE) {
if($contents === FALSE) {
echo "something went wrong";
} else {
$file = './updates/lotw_users.csv';
Expand Down Expand Up @@ -909,7 +909,7 @@ function lotw_satellite_map($satname) {

return array_search(strtoupper($satname),$arr,true);
}

/*
| Function: mode_map
| Requires: mode as $mode, submode as $submode
Expand Down
12 changes: 9 additions & 3 deletions application/models/Logbook_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ function eqsl_not_yet_sent() {
* $markQrz - used in ADIF import to mark QSOs as exported to QRZ Logbook when importing QSOs
* $skipexport - used in ADIF import to skip the realtime upload to QRZ Logbook when importing QSOs from ADIF
*/
function import($record, $station_id = "0", $skipDuplicate = false, $markLotw = false, $dxccAdif = false, $markQrz = false, $skipexport = false) {
function import($record, $station_id = "0", $skipDuplicate = false, $markLotw = false, $dxccAdif = false, $markQrz = false, $skipexport = false, $operatorName = false) {
$CI =& get_instance();
$CI->load->library('frequency');
$my_error = "";
Expand Down Expand Up @@ -1805,6 +1805,12 @@ function import($record, $station_id = "0", $skipDuplicate = false, $markLotw =
}
}

if ($operatorName != false) {
$operatorName = $this->session->userdata('user_callsign');
} else {
$operatorName = (!empty($record['operator'])) ? $record['operator'] : '';
}

// If user checked to mark QSOs as uploaded to QRZ Logbook, or else we try to find info in ADIF import.
if ($markQrz != null) {
$input_qrzcom_qso_upload_status = 'Y';
Expand Down Expand Up @@ -1918,7 +1924,7 @@ function import($record, $station_id = "0", $skipDuplicate = false, $markLotw =
'COL_NOTES_INTL' => (!empty($record['notes_intl'])) ? $record['notes_intl'] : '',
'COL_NR_BURSTS' => (!empty($record['nr_bursts'])) ? $record['nr_bursts'] : null,
'COL_NR_PINGS' => (!empty($record['nr_pings'])) ? $record['nr_pings'] : null,
'COL_OPERATOR' => (!empty($record['operator'])) ? $record['operator'] : '',
'COL_OPERATOR' => $operatorName,
'COL_OWNER_CALLSIGN' => (!empty($record['owner_callsign'])) ? $record['owner_callsign'] : '',
'COL_PFX' => (!empty($record['pfx'])) ? $record['pfx'] : '',
'COL_PRECEDENCE' => (!empty($record['precedence'])) ? $record['precedence'] : '',
Expand Down Expand Up @@ -2170,7 +2176,7 @@ public function check_missing_dxcc_id($all){

print("$count updated\n");
}

public function check_missing_grid_id($all){
// get all records with no COL_GRIDSQUARE
$this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF");
Expand Down
9 changes: 9 additions & 0 deletions application/views/adif/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@
</div>
</div>

<div class="form-group row">
<div class="col-md-10">
<div class="form-check-inline">
<input class="form-check-input" type="checkbox" name="operatorName" value="1" id="operatorName">
<label class="form-check-label" for="operatorName">Always use login-callsign as operator-name on import</label>
</div>
</div>
</div>

<button type="submit" class="btn-sm btn-primary mb-2" value="Upload">Upload</button>
</form>
</div>
Expand Down