mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Merge branch 'dev' into calltester
This commit is contained in:
@@ -119,10 +119,23 @@ class API extends CI_Controller {
|
||||
|
||||
function create_station($key = '') {
|
||||
$this->load->model('api_model');
|
||||
|
||||
if ($this->api_model->access($key) == "No Key Found" || $this->api_model->access($key) == "Key Disabled") {
|
||||
$this->output->set_status_header(401)->set_content_type('application/json')->set_output(json_encode(['status' => 'error', 'message' => 'Auth Error, invalid key']));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->load->model('club_model');
|
||||
$userid = $this->api_model->key_userid($key);
|
||||
$created_by = $this->api_model->key_created_by($key);
|
||||
$club_perm = $this->club_model->get_permission_noui($userid,$created_by);
|
||||
if ($userid != $created_by) { // We're dealing with a Club Member/Member ADIF or Clubofficer
|
||||
if ((($club_perm ?? 0) == 3) || (($club_perm ?? 0) == 6)) { // Member or ADIF-Member? DENY
|
||||
$this->output->set_status_header(401)->set_content_type('application/json')->set_output(json_encode(['status' => 'error', 'message' => 'Auth Error, not enough grants for this operation']));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$raw = file_get_contents("php://input");
|
||||
if ($raw === false) {
|
||||
@@ -149,8 +162,7 @@ class API extends CI_Controller {
|
||||
$this->output->set_status_header(500)->set_content_type('application/json')->set_output(json_encode(['status' => 'error', 'message' => 'Processing error: ' . $e->getMessage()]));
|
||||
}
|
||||
$this->load->model('stationsetup_model');
|
||||
$user_id = $this->api_model->key_userid($key);
|
||||
$imported = $this->stationsetup_model->import_locations_parse($locations,$user_id);
|
||||
$imported = $this->stationsetup_model->import_locations_parse($locations,$userid);
|
||||
if (($imported[0] ?? '0') == 'limit') {
|
||||
$this->output->set_status_header(201)->set_content_type('application/json')->set_output(json_encode(['status' => 'success', 'message' => ($imported[1] ?? '0')." locations imported. Maximum limit of 1000 locations reached."]));
|
||||
} else {
|
||||
@@ -224,6 +236,7 @@ class API extends CI_Controller {
|
||||
$this->load->model('api_model');
|
||||
|
||||
$this->load->model('stations');
|
||||
$this->load->model('club_model');
|
||||
|
||||
if (!$this->load->is_loaded('Qra')) {
|
||||
$this->load->library('Qra');
|
||||
@@ -252,6 +265,7 @@ class API extends CI_Controller {
|
||||
|
||||
$userid = $this->api_model->key_userid($obj['key']);
|
||||
$created_by = $this->api_model->key_created_by($obj['key']);
|
||||
$club_perm = $this->club_model->get_permission_noui($userid,$created_by);
|
||||
|
||||
/**
|
||||
* As the API key user could use it also for clubstations we need to do an additional check here. Only if clubstations are enabled
|
||||
@@ -260,12 +274,11 @@ class API extends CI_Controller {
|
||||
* If the user is not the creator of the API key, it's likely a clubstation. In this case the callsign of the clubstation
|
||||
* can not be the same as the callsign of the user (operator call provided by the user). If this is the case, we need to use the callsign of the creator of the API key
|
||||
*/
|
||||
$real_operator = null;
|
||||
$real_operator = null; // real_operator is only filled if its a clubstation and the used key is created by an OP. otherwise its null
|
||||
if ($this->config->item('special_callsign')) {
|
||||
if ($userid != $created_by) {
|
||||
$this->load->model('user_model');
|
||||
$real_operator = $this->user_model->get_by_id($created_by)->row()->user_callsign;
|
||||
// TODO: It would be possible to check here if operator is allowed to use the clubstation, but this can be added later if needed
|
||||
} else {
|
||||
$real_operator = null;
|
||||
}
|
||||
@@ -327,6 +340,11 @@ class API extends CI_Controller {
|
||||
$record['operator'] = $real_operator;
|
||||
}
|
||||
|
||||
// in case the caller is an OP for a clubstation (real_operator is filled - see above) and the OP only has level 3 or 6 - take the OP from real_operator!
|
||||
if ($real_operator != null && ((($club_perm ?? 0) == 3) || (($club_perm ?? 0) == 6))) {
|
||||
$record['operator'] = $real_operator;
|
||||
}
|
||||
|
||||
if ((key_exists('gridsquare',$record)) && (($mygrid ?? '') != '') && (($record['gridsquare'] ?? '') != '') && (!(key_exists('distance',$record)))) {
|
||||
$record['distance'] = $this->qra->distance($mygrid, $record['gridsquare'], 'K');
|
||||
}
|
||||
|
||||
@@ -785,7 +785,6 @@ class Logbookadvanced extends CI_Controller {
|
||||
|
||||
header("Content-Type: application/json");
|
||||
print json_encode($q);
|
||||
|
||||
}
|
||||
|
||||
public function fixItuZones() {
|
||||
@@ -834,8 +833,11 @@ class Logbookadvanced extends CI_Controller {
|
||||
$this->load->model('logbookadvanced_model');
|
||||
$result = $this->logbookadvanced_model->check_missing_continent();
|
||||
|
||||
header("Content-Type: application/json");
|
||||
print json_encode($result);
|
||||
$data['result'] = $result;
|
||||
|
||||
$data['type'] = 'continent';
|
||||
|
||||
$this->load->view('logbookadvanced/showUpdateResult', $data);
|
||||
}
|
||||
|
||||
public function fixStateProgress() {
|
||||
@@ -874,14 +876,110 @@ class Logbookadvanced extends CI_Controller {
|
||||
}
|
||||
|
||||
public function updateDistances() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$this->load->model('logbookadvanced_model');
|
||||
$result = $this->logbookadvanced_model->update_distances_batch();
|
||||
|
||||
header("Content-Type: application/json");
|
||||
print json_encode($result);
|
||||
$data['result'] = $result;
|
||||
|
||||
$data['type'] = 'distance';
|
||||
|
||||
$this->load->view('logbookadvanced/showUpdateResult', $data);
|
||||
}
|
||||
|
||||
public function callbookDialog() {
|
||||
$this->load->view('logbookadvanced/callbookdialog');
|
||||
}
|
||||
|
||||
public function dbtoolsDialog() {
|
||||
$this->load->view('logbookadvanced/dbtoolsdialog');
|
||||
}
|
||||
|
||||
public function checkDb() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$type = $this->input->post('type', true);
|
||||
$this->load->model('logbookadvanced_model');
|
||||
|
||||
$data['result'] = $this->logbookadvanced_model->runCheckDb($type);
|
||||
if ($type == 'checkstate') {
|
||||
$this->load->view('logbookadvanced/statecheckresult', $data);
|
||||
} else {
|
||||
$data['type'] = $type;
|
||||
$this->load->view('logbookadvanced/checkresult', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function fixStateBatch() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('logbookadvanced_model');
|
||||
|
||||
$dxcc = $this->input->post('dxcc', true);
|
||||
$data['country'] = $this->input->post('country', true);
|
||||
|
||||
// Process for batch QSO state fix
|
||||
$result = $this->logbookadvanced_model->fixStateBatch($dxcc);
|
||||
|
||||
$data['result'] = $result;
|
||||
|
||||
$data['type'] = 'state';
|
||||
|
||||
$this->load->view('logbookadvanced/showUpdateResult', $data);
|
||||
}
|
||||
|
||||
public function openStateList() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$this->load->model('logbookadvanced_model');
|
||||
|
||||
$data['dxcc'] = $this->input->post('dxcc', true);
|
||||
$data['country'] = $this->input->post('country', true);
|
||||
|
||||
// Process for batch QSO state fix
|
||||
$data['qsos'] = $this->logbookadvanced_model->getStateListQsos($data['dxcc']);
|
||||
|
||||
$this->load->view('logbookadvanced/showStateQsos', $data);
|
||||
}
|
||||
|
||||
public function fixMissingDxcc() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$all = $this->input->post('all', true);
|
||||
$this->load->model('logbookadvanced_model');
|
||||
$result = $this->logbookadvanced_model->check_missing_dxcc_id($all);
|
||||
|
||||
$data['result'] = $result;
|
||||
$data['all'] = $all;
|
||||
$data['type'] = 'dxcc';
|
||||
|
||||
$this->load->view('logbookadvanced/showUpdateResult', $data);
|
||||
}
|
||||
|
||||
public function openMissingDxccList() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$this->load->model('logbookadvanced_model');
|
||||
|
||||
$data['qsos'] = $this->logbookadvanced_model->getMissingDxccQsos();
|
||||
|
||||
$this->load->view('logbookadvanced/showMissingDxccQsos', $data);
|
||||
}
|
||||
|
||||
public function batchFix() {
|
||||
if(!clubaccess_check(9)) return;
|
||||
|
||||
$type = $this->input->post('type', true);
|
||||
$this->load->model('logbookadvanced_model');
|
||||
$result = $this->logbookadvanced_model->batchFix($type);
|
||||
|
||||
$data['result'] = $result;
|
||||
$data['type'] = $type;
|
||||
|
||||
$this->load->view('logbookadvanced/showUpdateResult', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -316,37 +316,15 @@ class Update extends CI_Controller {
|
||||
|
||||
|
||||
private function fix_migrations(){
|
||||
$res = $this->db->query("SELECT version FROM migrations");
|
||||
if ($res->num_rows() >0){
|
||||
$row = $res->row();
|
||||
$version = $row->version;
|
||||
$res = $this->db->query("SELECT version FROM migrations");
|
||||
if ($res->num_rows() >0){
|
||||
$row = $res->row();
|
||||
$version = $row->version;
|
||||
|
||||
if ($version < 7){
|
||||
$this->db->query("UPDATE migrations SET version=7");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function check_missing_dxcc($all = false){
|
||||
$this->load->model('user_model');
|
||||
if (!$this->user_model->authorize(99)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
if ($version < 7){
|
||||
$this->db->query("UPDATE migrations SET version=7");
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$this->logbook_model->check_missing_dxcc_id($all);
|
||||
}
|
||||
|
||||
public function check_missing_grid($all = false){
|
||||
$this->load->model('user_model');
|
||||
if (!$this->user_model->authorize(99)) {
|
||||
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
$this->logbook_model->check_missing_grid_id($all);
|
||||
}
|
||||
|
||||
public function update_clublog_scp() {
|
||||
|
||||
Reference in New Issue
Block a user