diff --git a/app/Presentation/@layout.latte b/app/Presentation/@layout.latte
index 76881d9..261b7b7 100644
--- a/app/Presentation/@layout.latte
+++ b/app/Presentation/@layout.latte
@@ -58,6 +58,7 @@
Zvěstovatelé
Odhlásit
{else}
+ Home
Přihlásit
{/if}
diff --git a/app/Presentation/BasePresenter.php b/app/Presentation/BasePresenter.php
new file mode 100644
index 0000000..a3196b8
--- /dev/null
+++ b/app/Presentation/BasePresenter.php
@@ -0,0 +1,20 @@
+getUser()->isLoggedIn()) {
+ $this->flashMessage('Pro tuto agendu se přihlaste.');
+ $this->redirect(':Sign:in', ['backlink' => $this->storeRequest()]);
+ }
+ }
+}
diff --git a/app/Presentation/Mapa/MapaPresenter.php b/app/Presentation/Mapa/MapaPresenter.php
index e51126c..591d2d6 100644
--- a/app/Presentation/Mapa/MapaPresenter.php
+++ b/app/Presentation/Mapa/MapaPresenter.php
@@ -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
{
+ $prihlaseny = $this->getUser()->isLoggedIn();
$povolene = ['obvody', 'stari', 'nedokoncene'];
- if (!in_array($filtr, $povolene, true)) {
+ if (!$prihlaseny || !in_array($filtr, $povolene, true)) {
$filtr = 'obvody';
}
- $stari = $this->zaznam->getStariObvodu();
- foreach ($stari as &$polozka) {
- $polozka['url'] = $this->link('Obvod:view', $polozka['id']);
+ $stari = [];
+ if ($prihlaseny) {
+ $stari = $this->zaznam->getStariObvodu();
+ foreach ($stari as &$polozka) {
+ $polozka['url'] = $this->link('Obvod:view', $polozka['id']);
+ }
+ unset($polozka);
}
- unset($polozka);
+ $this->template->prihlaseny = $prihlaseny;
$this->template->obvod_id = $obvod;
$this->template->filtr = $filtr;
$this->template->maxMesicu = self::STUPNICE_MESICU;
diff --git a/app/Presentation/Mapa/default.latte b/app/Presentation/Mapa/default.latte
index 1de7784..9d7a855 100644
--- a/app/Presentation/Mapa/default.latte
+++ b/app/Presentation/Mapa/default.latte
@@ -6,9 +6,10 @@
data-max="{$maxMesicu}"
data-prideleni="{$maxPrideleni}"
data-filtr="{$filtr}"
+ data-prihlaseny="{if $prihlaseny}1{else}0{/if}"
data-obvod="{if $obvod_id}{$obvod_id}{/if}">
-
+
{/block}
diff --git a/app/Presentation/Obvod/ObvodPresenter.php b/app/Presentation/Obvod/ObvodPresenter.php
index 0fbefac..dbaf151 100644
--- a/app/Presentation/Obvod/ObvodPresenter.php
+++ b/app/Presentation/Obvod/ObvodPresenter.php
@@ -6,13 +6,14 @@ namespace App\Presentation\Obvod;
use App\Model\ObvodFacade;
use App\Model\ZaznamFacade;
+use App\Presentation\BasePresenter;
use Nette;
use Nette\Application\UI\Form;
use Nette\Application\UI\Multiplier;
use Nette\Utils\ArrayHash;
-final class ObvodPresenter extends Nette\Application\UI\Presenter
+final class ObvodPresenter extends BasePresenter
{
private string $skupina = '';
diff --git a/app/Presentation/Stari/StariPresenter.php b/app/Presentation/Stari/StariPresenter.php
index af85035..0709cdc 100644
--- a/app/Presentation/Stari/StariPresenter.php
+++ b/app/Presentation/Stari/StariPresenter.php
@@ -4,10 +4,10 @@ declare(strict_types=1);
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
{
diff --git a/app/Presentation/Zvestovatel/ZvestovatelPresenter.php b/app/Presentation/Zvestovatel/ZvestovatelPresenter.php
index c54c8ea..10d43f4 100644
--- a/app/Presentation/Zvestovatel/ZvestovatelPresenter.php
+++ b/app/Presentation/Zvestovatel/ZvestovatelPresenter.php
@@ -5,12 +5,13 @@ declare(strict_types=1);
namespace App\Presentation\Zvestovatel;
use App\Model\ZvestovatelFacade;
+use App\Presentation\BasePresenter;
use Nette;
use Nette\Application\UI\Form;
use Nette\Utils\ArrayHash;
-final class ZvestovatelPresenter extends Nette\Application\UI\Presenter
+final class ZvestovatelPresenter extends BasePresenter
{
public function __construct(
private ZvestovatelFacade $zvestovatele,
diff --git a/www/js/stari.js b/www/js/stari.js
index b44af1f..d9668e0 100644
--- a/www/js/stari.js
+++ b/www/js/stari.js
@@ -10,8 +10,9 @@
var maxPrideleni = parseInt(mapaEl.getAttribute('data-prideleni'), 10) || 12;
var geojsonUrl = mapaEl.getAttribute('data-geojson');
var obvodId = mapaEl.getAttribute('data-obvod');
+ var prihlaseny = mapaEl.getAttribute('data-prihlaseny') === '1';
var rezim = mapaEl.getAttribute('data-filtr');
- if (rezim !== 'stari' && rezim !== 'nedokoncene') {
+ if (!prihlaseny || (rezim !== 'stari' && rezim !== 'nedokoncene')) {
rezim = 'obvody';
}
@@ -175,7 +176,9 @@
return div;
},
});
- new Filtr().addTo(map);
+ if (prihlaseny) {
+ new Filtr().addTo(map);
+ }
function textMesicu(mesice) {
if (mesice == null) {
@@ -290,6 +293,9 @@
var znacky = null;
function popupHtml(cislo, info) {
+ if (!prihlaseny) {
+ return 'Obvod č. ' + cislo + '';
+ }
var html = 'Obvod č. ' + cislo + '
';
if (!info || info.vraceno == null) {
html += 'Zatím bez propracování';
@@ -594,7 +600,7 @@
}
function nastavRezim(novy) {
- if (novy !== 'stari' && novy !== 'nedokoncene') {
+ if (!prihlaseny || (novy !== 'stari' && novy !== 'nedokoncene')) {
novy = 'obvody';
}
if (novy === rezim) {