Oprávnění

master
Kowalski 2026-10-11 20:25:30 +02:00
parent 8e105ac21c
commit 5c4e87af7c
8 changed files with 55 additions and 13 deletions

View File

@ -58,6 +58,7 @@
<a class='nav-link' n:href=':Zvestovatel:'>Zvěstovatelé</a> <a class='nav-link' n:href=':Zvestovatel:'>Zvěstovatelé</a>
<a class='nav-link' n:href=":Sign:out">Odhlásit</a> <a class='nav-link' n:href=":Sign:out">Odhlásit</a>
{else} {else}
<a class='nav-link' n:href=':Home:'>Home</a>
<a class='nav-link' n:href=':Sign:in'>Přihlásit</a> <a class='nav-link' n:href=':Sign:in'>Přihlásit</a>
{/if} {/if}
</div> </div>

View File

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Presentation;
use Nette;
abstract class BasePresenter extends Nette\Application\UI\Presenter
{
protected function startup(): void
{
parent::startup();
if (!$this->getUser()->isLoggedIn()) {
$this->flashMessage('Pro tuto agendu se přihlaste.');
$this->redirect(':Sign:in', ['backlink' => $this->storeRequest()]);
}
}
}

View File

@ -22,19 +22,31 @@ final class MapaPresenter extends Nette\Application\UI\Presenter
) { ) {
} }
public function actionDefault(?int $obvod = null, ?string $filtr = null): void
{
if (!$this->getUser()->isLoggedIn() && $filtr !== null && $filtr !== 'obvody') {
$this->redirect('this', ['obvod' => $obvod, 'filtr' => null]);
}
}
public function renderDefault(?int $obvod = null, ?string $filtr = null): void public function renderDefault(?int $obvod = null, ?string $filtr = null): void
{ {
$prihlaseny = $this->getUser()->isLoggedIn();
$povolene = ['obvody', 'stari', 'nedokoncene']; $povolene = ['obvody', 'stari', 'nedokoncene'];
if (!in_array($filtr, $povolene, true)) { if (!$prihlaseny || !in_array($filtr, $povolene, true)) {
$filtr = 'obvody'; $filtr = 'obvody';
} }
$stari = [];
if ($prihlaseny) {
$stari = $this->zaznam->getStariObvodu(); $stari = $this->zaznam->getStariObvodu();
foreach ($stari as &$polozka) { foreach ($stari as &$polozka) {
$polozka['url'] = $this->link('Obvod:view', $polozka['id']); $polozka['url'] = $this->link('Obvod:view', $polozka['id']);
} }
unset($polozka); unset($polozka);
}
$this->template->prihlaseny = $prihlaseny;
$this->template->obvod_id = $obvod; $this->template->obvod_id = $obvod;
$this->template->filtr = $filtr; $this->template->filtr = $filtr;
$this->template->maxMesicu = self::STUPNICE_MESICU; $this->template->maxMesicu = self::STUPNICE_MESICU;

View File

@ -6,9 +6,10 @@
data-max="{$maxMesicu}" data-max="{$maxMesicu}"
data-prideleni="{$maxPrideleni}" data-prideleni="{$maxPrideleni}"
data-filtr="{$filtr}" data-filtr="{$filtr}"
data-prihlaseny="{if $prihlaseny}1{else}0{/if}"
data-obvod="{if $obvod_id}{$obvod_id}{/if}"></div> data-obvod="{if $obvod_id}{$obvod_id}{/if}"></div>
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" />
<script src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script> <script src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script>
<script type="application/json" id="stari-data">{$stariJson|noescape}</script> <script type="application/json" id="stari-data">{$stariJson|noescape}</script>
<script src="{$basePath}/js/stari.js?v=9"></script> <script src="{$basePath}/js/stari.js?v=10"></script>
{/block} {/block}

View File

@ -6,13 +6,14 @@ namespace App\Presentation\Obvod;
use App\Model\ObvodFacade; use App\Model\ObvodFacade;
use App\Model\ZaznamFacade; use App\Model\ZaznamFacade;
use App\Presentation\BasePresenter;
use Nette; use Nette;
use Nette\Application\UI\Form; use Nette\Application\UI\Form;
use Nette\Application\UI\Multiplier; use Nette\Application\UI\Multiplier;
use Nette\Utils\ArrayHash; use Nette\Utils\ArrayHash;
final class ObvodPresenter extends Nette\Application\UI\Presenter final class ObvodPresenter extends BasePresenter
{ {
private string $skupina = ''; private string $skupina = '';

View File

@ -4,10 +4,10 @@ declare(strict_types=1);
namespace App\Presentation\Stari; namespace App\Presentation\Stari;
use Nette; use App\Presentation\BasePresenter;
final class StariPresenter extends Nette\Application\UI\Presenter final class StariPresenter extends BasePresenter
{ {
public function actionDefault(): void public function actionDefault(): void
{ {

View File

@ -5,12 +5,13 @@ declare(strict_types=1);
namespace App\Presentation\Zvestovatel; namespace App\Presentation\Zvestovatel;
use App\Model\ZvestovatelFacade; use App\Model\ZvestovatelFacade;
use App\Presentation\BasePresenter;
use Nette; use Nette;
use Nette\Application\UI\Form; use Nette\Application\UI\Form;
use Nette\Utils\ArrayHash; use Nette\Utils\ArrayHash;
final class ZvestovatelPresenter extends Nette\Application\UI\Presenter final class ZvestovatelPresenter extends BasePresenter
{ {
public function __construct( public function __construct(
private ZvestovatelFacade $zvestovatele, private ZvestovatelFacade $zvestovatele,

View File

@ -10,8 +10,9 @@
var maxPrideleni = parseInt(mapaEl.getAttribute('data-prideleni'), 10) || 12; var maxPrideleni = parseInt(mapaEl.getAttribute('data-prideleni'), 10) || 12;
var geojsonUrl = mapaEl.getAttribute('data-geojson'); var geojsonUrl = mapaEl.getAttribute('data-geojson');
var obvodId = mapaEl.getAttribute('data-obvod'); var obvodId = mapaEl.getAttribute('data-obvod');
var prihlaseny = mapaEl.getAttribute('data-prihlaseny') === '1';
var rezim = mapaEl.getAttribute('data-filtr'); var rezim = mapaEl.getAttribute('data-filtr');
if (rezim !== 'stari' && rezim !== 'nedokoncene') { if (!prihlaseny || (rezim !== 'stari' && rezim !== 'nedokoncene')) {
rezim = 'obvody'; rezim = 'obvody';
} }
@ -175,7 +176,9 @@
return div; return div;
}, },
}); });
if (prihlaseny) {
new Filtr().addTo(map); new Filtr().addTo(map);
}
function textMesicu(mesice) { function textMesicu(mesice) {
if (mesice == null) { if (mesice == null) {
@ -290,6 +293,9 @@
var znacky = null; var znacky = null;
function popupHtml(cislo, info) { function popupHtml(cislo, info) {
if (!prihlaseny) {
return '<strong>Obvod č. ' + cislo + '</strong>';
}
var html = '<strong>Obvod č. ' + cislo + '</strong><br>'; var html = '<strong>Obvod č. ' + cislo + '</strong><br>';
if (!info || info.vraceno == null) { if (!info || info.vraceno == null) {
html += 'Zatím bez propracování'; html += 'Zatím bez propracování';
@ -594,7 +600,7 @@
} }
function nastavRezim(novy) { function nastavRezim(novy) {
if (novy !== 'stari' && novy !== 'nedokoncene') { if (!prihlaseny || (novy !== 'stari' && novy !== 'nedokoncene')) {
novy = 'obvody'; novy = 'obvody';
} }
if (novy === rezim) { if (novy === rezim) {