From 42adfc7d6331b66f27675792c54f748186739184 Mon Sep 17 00:00:00 2001 From: Bohumir Zamecnik Date: Sun, 8 Jul 2012 13:12:42 +0200 Subject: [PATCH] Make Song and Attendance available only to authorized users. Also fix the active state of a navbar link. --- nette/app/components/AttendanceButton.latte | 25 +++++++++++++------- nette/app/presenters/AttendancePresenter.php | 4 ++++ nette/app/presenters/SongPresenter.php | 8 +++++++ nette/app/templates/Attendance/event.latte | 6 +++-- nette/app/templates/navbar.latte | 4 +++- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/nette/app/components/AttendanceButton.latte b/nette/app/components/AttendanceButton.latte index 568b845..98c9f76 100644 --- a/nette/app/components/AttendanceButton.latte +++ b/nette/app/components/AttendanceButton.latte @@ -4,16 +4,25 @@ {/define} +{if $user->isLoggedIn()}
- - -
\ No newline at end of file + + +{else} +
+ +
+{/if} diff --git a/nette/app/presenters/AttendancePresenter.php b/nette/app/presenters/AttendancePresenter.php index 212f91a..f226bec 100644 --- a/nette/app/presenters/AttendancePresenter.php +++ b/nette/app/presenters/AttendancePresenter.php @@ -26,6 +26,8 @@ class AttendancePresenter extends BasePresenter // TODO: try to merge actionCreate() and actionEdit() public function actionCreate($eventId, $memberId) { + $this->ensureLoggedUser(); + $this->event = $this->context->createEvents()->get($eventId); $this->member = $this->context->createMembers()->get($memberId); if (!$this->event or !$this->member) { @@ -45,6 +47,8 @@ public function actionCreate($eventId, $memberId) { } public function actionEdit($id) { + $this->ensureLoggedUser(); + $this->attendance = $this->context->createAttendances()->get($id); if (!$this->attendance) { $this->flashMessage('Nelze nastavit účast, neboť zadaná událost nebo osoba neexistuje.', 'error'); diff --git a/nette/app/presenters/SongPresenter.php b/nette/app/presenters/SongPresenter.php index e84097f..1782421 100644 --- a/nette/app/presenters/SongPresenter.php +++ b/nette/app/presenters/SongPresenter.php @@ -13,8 +13,14 @@ class SongPresenter extends BasePresenter private $query; + public function actionDefault() { + $this->ensureLoggedUser(); + } + public function actionDetails($id) { + $this->ensureLoggedUser(); + $this->song = $this->context->createSongs()->get($id); if ($this->song === FALSE) { $this->setView('notFound'); @@ -49,6 +55,8 @@ public function actionDelete($id) public function actionSearch($query) { + $this->ensureLoggedUser(); + $this->query = $query; $this["searchForm"]->setDefaults(array('query' => $this->query)); } diff --git a/nette/app/templates/Attendance/event.latte b/nette/app/templates/Attendance/event.latte index ede50da..99d32be 100644 --- a/nette/app/templates/Attendance/event.latte +++ b/nette/app/templates/Attendance/event.latte @@ -74,12 +74,14 @@ {$memberAtt->attend_note} - + {if $user->isLoggedIn()} - + + + {/if} {/foreach} diff --git a/nette/app/templates/navbar.latte b/nette/app/templates/navbar.latte index 5722371..b75e97d 100644 --- a/nette/app/templates/navbar.latte +++ b/nette/app/templates/navbar.latte @@ -19,9 +19,11 @@  Účast na akcích - + {if $user->isLoggedIn()} +  Písničky + {/if}