added hrdlog_username
这个提交包含在:
父节点
29236fabb2
当前提交
fc793a1160
共有 7 个文件被更改,包括 66 次插入 和 22 次删除
|
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
|||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 161;
|
||||
$config['migration_version'] = 162;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ class Hrdlog extends CI_Controller {
|
|||
|
||||
if ($station_ids) {
|
||||
foreach ($station_ids as $station) {
|
||||
$hrdlog_username = $station->hrdlog_username;
|
||||
$hrdlog_code = $station->hrdlog_code;
|
||||
if($this->mass_upload_qsos($station->station_id, $hrdlog_code)) {
|
||||
if($this->mass_upload_qsos($station->station_id, $hrdlog_username, $hrdlog_code)) {
|
||||
echo "QSOs have been uploaded to hrdlog.net.";
|
||||
log_message('info', 'QSOs have been uploaded to hrdlog.net.');
|
||||
} else{
|
||||
|
|
@ -48,7 +49,7 @@ class Hrdlog extends CI_Controller {
|
|||
* Function gets all QSOs from given station_id, that are not previously uploaded to hrdlog.
|
||||
* Adif is build for each qso, and then uploaded, one at a time
|
||||
*/
|
||||
function mass_upload_qsos($station_id, $hrdlog_code) {
|
||||
function mass_upload_qsos($station_id, $hrdlog_username, $hrdlog_code) {
|
||||
$i = 0;
|
||||
$data['qsos'] = $this->logbook_model->get_hrdlog_qsos($station_id);
|
||||
$errormessages=array();
|
||||
|
|
@ -61,9 +62,9 @@ class Hrdlog extends CI_Controller {
|
|||
$adif = $CI->adifhelper->getAdifLine($qso);
|
||||
|
||||
if ($qso->COL_HRDLOG_QSO_UPLOAD_STATUS == 'M') {
|
||||
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif, true);
|
||||
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif, true);
|
||||
} else {
|
||||
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_code, $qso->COL_STATION_CALLSIGN,$adif);
|
||||
$result = $this->logbook_model->push_qso_to_hrdlog($hrdlog_username, $hrdlog_code, $adif);
|
||||
}
|
||||
|
||||
if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate')) ){
|
||||
|
|
@ -126,10 +127,11 @@ class Hrdlog extends CI_Controller {
|
|||
$postData = $this->input->post();
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$result = $this->logbook_model->exists_hrdlog_code($postData['station_id']);
|
||||
$result = $this->logbook_model->exists_hrdlog_credentials($postData['station_id']);
|
||||
$hrdlog_username = $result->hrdlog_username;
|
||||
$hrdlog_code = $result->hrdlog_code;
|
||||
header('Content-type: application/json');
|
||||
$result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_code);
|
||||
$result = $this->mass_upload_qsos($postData['station_id'], $hrdlog_username, $hrdlog_code);
|
||||
if ($result['status'] == 'OK') {
|
||||
$stationinfo = $this->stations->stations_with_hrdlog_code();
|
||||
$info = $stationinfo->result();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* This adds the hrdlog username to the station profile as this is needed
|
||||
* for special callsigns
|
||||
*/
|
||||
|
||||
class Migration_hrdlog_username extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
if (!$this->db->field_exists('hrdlog_username', 'station_profile')) {
|
||||
$fields = array(
|
||||
'hrdlog_username VARCHAR(20) DEFAULT NULL AFTER hrdlog_code',
|
||||
);
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if ($this->db->field_exists('hrdlog_username', 'station_profile')) {
|
||||
$this->dbforge->drop_column('station_profile', 'hrdlog_username');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -278,7 +278,7 @@ class Logbook_model extends CI_Model {
|
|||
$data['COL_MY_GRIDSQUARE'] = strtoupper(trim($station['station_gridsquare']));
|
||||
}
|
||||
|
||||
if ($this->exists_hrdlog_code($station_id)) {
|
||||
if ($this->exists_hrdlog_credentials($station_id)) {
|
||||
$data['COL_HRDLOG_QSO_UPLOAD_STATUS'] = 'N';
|
||||
}
|
||||
|
||||
|
|
@ -602,15 +602,15 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
$result = '';
|
||||
$result = $this->exists_hrdlog_code($data['station_id']);
|
||||
$result = $this->exists_hrdlog_credentials($data['station_id']);
|
||||
// Push qso to hrdlog if code is set, and realtime upload is enabled, and we're not importing an adif-file
|
||||
if (isset($result->hrdlog_code) && $result->hrdlogrealtime == 1) {
|
||||
if (isset($result->hrdlog_code) && isset($result->hrdlog_username) && $result->hrdlogrealtime == 1) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
$qso = $this->get_qso($last_id,true)->result();
|
||||
|
||||
$adif = $CI->adifhelper->getAdifLine($qso[0]);
|
||||
$result = $this->push_qso_to_hrdlog($result->hrdlog_code, $data['COL_STATION_CALLSIGN'], $adif);
|
||||
$result = $this->push_qso_to_hrdlog($result->hrdlog_username, $result->hrdlog_code, $adif);
|
||||
if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate') || ($result['status'] == 'auth_error') )){
|
||||
$this->mark_hrdlog_qsos_sent($last_id);
|
||||
}
|
||||
|
|
@ -652,10 +652,10 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
|
||||
/*
|
||||
* Function checks if a HRDLog Code exists in the table with the given station id
|
||||
* Function checks if a HRDLog Code and Username exists in the table with the given station id
|
||||
*/
|
||||
function exists_hrdlog_code($station_id) {
|
||||
$sql = 'select hrdlog_code, hrdlogrealtime from station_profile
|
||||
function exists_hrdlog_credentials($station_id) {
|
||||
$sql = 'select hrdlog_username, hrdlog_code, hrdlogrealtime from station_profile
|
||||
where station_id = ?';
|
||||
|
||||
$query = $this->db->query($sql,$station_id);
|
||||
|
|
@ -762,7 +762,7 @@ class Logbook_model extends CI_Model {
|
|||
* Function uploads a QSO to HRDLog with the API given.
|
||||
* $adif contains a line with the QSO in the ADIF format. QSO ends with an <EOR>
|
||||
*/
|
||||
function push_qso_to_hrdlog($apikey, $station_callsign, $adif, $replaceoption = false) {
|
||||
function push_qso_to_hrdlog($hrdlog_username, $apikey, $adif, $replaceoption = false) {
|
||||
$url = 'https://robot.hrdlog.net/newentry.aspx';
|
||||
|
||||
$post_data['Code'] = $apikey;
|
||||
|
|
@ -772,7 +772,7 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
$post_data['ADIFData'] = $adif;
|
||||
|
||||
$post_data['Callsign'] = $station_callsign;
|
||||
$post_data['Callsign'] = $hrdlog_username;
|
||||
|
||||
|
||||
$post_encoded=http_build_query($post_data);
|
||||
|
|
@ -1213,7 +1213,7 @@ class Logbook_model extends CI_Model {
|
|||
'COL_CNTY' => $uscounty
|
||||
);
|
||||
|
||||
if ($this->exists_hrdlog_code($data['station_id'])) {
|
||||
if ($this->exists_hrdlog_credentials($data['station_id'])) {
|
||||
$data['COL_HRDLOG_QSO_UPLOAD_STATUS'] = 'M';
|
||||
}
|
||||
|
||||
|
|
@ -1745,9 +1745,11 @@ class Logbook_model extends CI_Model {
|
|||
* Function returns all the station_id's with HRDLOG Code
|
||||
*/
|
||||
function get_station_id_with_hrdlog_code() {
|
||||
$sql = 'select station_id, hrdlog_code from station_profile
|
||||
where coalesce(hrdlog_code, "") <> ""';
|
||||
|
||||
$sql = 'SELECT station_id, hrdlog_username, hrdlog_code
|
||||
FROM station_profile
|
||||
WHERE coalesce(hrdlog_username, "") <> ""
|
||||
AND coalesce(hrdlog_code, "") <> ""';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$result = $query->result();
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ class Stations extends CI_Model {
|
|||
'station_itu' => xss_clean($this->input->post('station_itu', true)),
|
||||
'state' => $state,
|
||||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'hrdlog_username' => xss_clean($this->input->post('hrdlog_username', true)),
|
||||
'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)),
|
||||
'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)),
|
||||
'clublogrealtime' => xss_clean($this->input->post('clublogrealtime', true)),
|
||||
|
|
@ -150,6 +151,7 @@ class Stations extends CI_Model {
|
|||
'station_itu' => xss_clean($this->input->post('station_itu', true)),
|
||||
'state' => $state,
|
||||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'hrdlog_username' => xss_clean($this->input->post('hrdlog_username', true)),
|
||||
'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)),
|
||||
'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)),
|
||||
'clublogrealtime' => xss_clean($this->input->post('clublogrealtime', true)),
|
||||
|
|
|
|||
|
|
@ -265,12 +265,17 @@
|
|||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="mb-3 col-sm-6">
|
||||
<div class="mb-3 col-sm-3">
|
||||
<label for="hrdlog_username">HRDLog.net Username</label>
|
||||
<input type="text" class="form-control" name="hrdlog_username" id="hrdlog_username" aria-describedby="hrdlog_usernameHelp">
|
||||
<small id="hrdlog_usernameHelp" class="form-text text-muted">Your HRDlog Username</a></small>
|
||||
</div>
|
||||
<div class="mb-3 col-sm-3">
|
||||
<label for="hrdlog_code">HRDLog.net API Code</label> <!-- This does not need Multilanguage Support -->
|
||||
<input type="text" class="form-control" name="hrdlog_code" id="hrdlog_code" aria-describedby="hrdlog_codeHelp">
|
||||
<small id="hrdlog_codeHelp" class="form-text text-muted"><?php echo lang("station_location_hrdlog_hint"); ?></a></small>
|
||||
</div>
|
||||
<div class="mb-3 col-sm-6">
|
||||
<div class="mb-3 col-sm-3">
|
||||
<label for="hrdlogrealtime"><?php echo lang("station_location_hrdlog_realtime_upload"); ?></label>
|
||||
<select class="form-select" id="hrdlogrealtime" name="hrdlogrealtime">
|
||||
<option value="1"><?php echo lang("general_word_yes"); ?></option>
|
||||
|
|
|
|||
|
|
@ -406,6 +406,11 @@
|
|||
<div class="card">
|
||||
<h5 class="card-header">HRDLog.net</h5> <!-- This does not need Multilanguage Support -->
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="webadifApiKey">HRDLog.net Username</label>
|
||||
<input type="text" class="form-control" name="hrdlog_username" id="hrdlog_username" aria-describedby="hrdlog_usernameHelp" value="<?php if(set_value('hrdlog_username') != "") { echo set_value('hrdlog_username'); } else { echo $my_station_profile->hrdlog_username; } ?>">
|
||||
<small id="hrdlog_usernameHelp" class="form-text text-muted">Your HRDlog Username</a></small>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="webadifApiKey">HRDLog.net API Code</label> <!-- This does not need Multilanguage Support -->
|
||||
<input type="text" class="form-control" name="hrdlog_code" id="hrdlog_code" aria-describedby="hrdlog_codeHelp" value="<?php if(set_value('hrdlog_code') != "") { echo set_value('hrdlog_code'); } else { echo $my_station_profile->hrdlog_code; } ?>">
|
||||
|
|
|
|||
正在加载…
在新工单中引用