wavelog/application/controllers/Activators.php

68 lines
2.2 KiB
PHP
Raw Permalink Normal View History

<?php
2024-05-24 22:14:42 +02:00
defined('BASEPATH') OR exit('No direct script access allowed');
2024-05-24 20:49:18 +02:00
class Activators extends CI_Controller
{
function __construct()
{
parent::__construct();
2024-05-24 20:49:18 +02:00
if (!$this->user_model->authorize(2)) {
2024-08-16 10:08:44 +02:00
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
2024-05-24 20:49:18 +02:00
redirect('dashboard');
}
}
public function index()
{
2024-06-08 11:01:59 +02:00
$data['page_title'] = __("Gridsquare Activators");
2026-06-18 11:47:32 +02:00
$validHex = function($color, $default) {
return preg_match('/^#[0-9a-fA-F]{6}$/', $color ?? '') ? $color : $default;
};
$map_custom_colors = json_decode($this->optionslib->get_map_custom());
2026-06-18 11:47:32 +02:00
$color_confirmed = $map_custom_colors->qsoconfirm->color;
list($r, $g, $b) = sscanf($validHex($color_confirmed ?? '', '#90EE90'), "#%02x%02x%02x");
2026-06-18 11:12:53 +02:00
$data['grid_color'] = "rgba(".$r.", ".$g.", ".$b.", 0.6)";
$this->load->model('Activators_model');
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
$band = $this->input->post('band');
2024-05-24 20:49:18 +02:00
} else {
$band = 'All';
}
2024-05-24 23:09:58 +02:00
if ($this->input->post('mincount') != NULL) { // mincount is not set when page first loads.
$mincount = $this->input->post('mincount');
} else {
$mincount = 2;
2024-05-24 23:09:58 +02:00
}
2024-05-24 23:15:02 +02:00
if ($this->input->post('leogeo') != NULL) { // orbit is not set when page first loads.
$orbit = $this->input->post('leogeo');
2024-05-24 23:09:58 +02:00
} else {
$orbit = 'both';
}
$this->load->model('bands');
$data['worked_bands'] = $this->bands->get_worked_bands();
2024-05-24 23:09:58 +02:00
$data['mincount'] = $mincount;
$data['maxactivatedgrids'] = $this->Activators_model->get_max_activated_grids();
2024-05-24 23:09:58 +02:00
$data['orbit'] = $orbit;
$data['activators_array'] = $this->Activators_model->get_activators($band, $mincount, $orbit);
$data['bandselect'] = $band;
2024-05-24 21:36:46 +02:00
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/activators.js',
2024-05-24 21:36:46 +02:00
];
$this->load->view('interface_assets/header', $data);
$this->load->view('activators/index');
2024-05-24 21:36:46 +02:00
$this->load->view('interface_assets/footer', $footerData);
}
}