Skip to content

Commit

Permalink
Make Song and Attendance available only to authorized users.
Browse files Browse the repository at this point in the history
Also fix the active state of a navbar link.
  • Loading branch information
bzamecnik committed Jul 8, 2012
1 parent 0d99ce2 commit 42adfc7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
25 changes: 17 additions & 8 deletions nette/app/components/AttendanceButton.latte
Expand Up @@ -4,16 +4,25 @@
</li>
{/define}

{if $user->isLoggedIn()}
<div class="btn-group">
<button class="btn dropdown-toggle {$attendButtonStyles[$attendText]}" data-toggle="dropdown">
<button class="btn dropdown-toggle {$attendButtonStyles[$attendText]}" data-toggle="dropdown">
<i class="{($attend !== NULL) ? icon-white} {$attendIcons[$attendText]}">
</i>&nbsp;{$attendButtonTexts[$attendText]}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{include #buttonItem, text => 'Účastním se', attendValue => 1, attendIcon => 'yes'}
{include #buttonItem, text => 'Neúčastním se', attendValue => 0, attendIcon => 'no'}
<li class="divider"></li>
{include #buttonItem, text => 'Nevyplněno', attendValue => null, attendIcon => 'null'}
</ul>
</div>
<ul class="dropdown-menu">
{include #buttonItem, text => 'Účastním se', attendValue => 1, attendIcon => 'yes'}
{include #buttonItem, text => 'Neúčastním se', attendValue => 0, attendIcon => 'no'}
<li class="divider"></li>
{include #buttonItem, text => 'Nevyplněno', attendValue => null, attendIcon => 'null'}
</ul>
</div>
{else}
<div class="btn-group">
<button class="btn {$attendButtonStyles[$attendText]}">
<i class="{($attend !== NULL) ? icon-white} {$attendIcons[$attendText]}">
</i>&nbsp;{$attendButtonTexts[$attendText]}
</button>
</div>
{/if}
4 changes: 4 additions & 0 deletions nette/app/presenters/AttendancePresenter.php
Expand Up @@ -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) {
Expand All @@ -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');
Expand Down
8 changes: 8 additions & 0 deletions nette/app/presenters/SongPresenter.php
Expand Up @@ -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');
Expand Down Expand Up @@ -49,6 +55,8 @@ public function actionDelete($id)

public function actionSearch($query)
{
$this->ensureLoggedUser();

$this->query = $query;
$this["searchForm"]->setDefaults(array('query' => $this->query));
}
Expand Down
6 changes: 4 additions & 2 deletions nette/app/templates/Attendance/event.latte
Expand Up @@ -74,12 +74,14 @@
</td>
<td>{$memberAtt->attend_note}</td>
<td>

{if $user->isLoggedIn()}
<a class="btn" href="{if $memberAtt->attendance_id}
{plink Attendance:edit $memberAtt->attendance_id}{else}
{plink Attendance:create eventId => $event->id, memberId => $memberAtt->member_id}
{/if}" title="Upravit">
<i class="icon-pencil"></i></a>
<i class="icon-pencil"></i>
</a>
{/if}
</td>
</tr>
{/foreach}
Expand Down
4 changes: 3 additions & 1 deletion nette/app/templates/navbar.latte
Expand Up @@ -19,9 +19,11 @@
<li{ifCurrent Attendance:*} class="active"{/ifCurrent}>
<a n:href="Attendance:" title="Kdo může dorazit na kterou akci?"><i class="icon-check icon-white"></i>&nbsp;Účast na akcích</a>
</li>
<li{ifCurrent Attendance:*} class="active"{/ifCurrent}>
{if $user->isLoggedIn()}
<li{ifCurrent Song:*} class="active"{/ifCurrent}>
<a n:href="Song:" title="Písničky, které zpíváme."><i class="icon-music icon-white"></i>&nbsp;Písničky</a>
</li>
{/if}
</ul>
<ul class="nav pull-right">
<li><a href="http://corale.cz/" title="Hlavní stránka sboru Corale">
Expand Down

0 comments on commit 42adfc7

Please sign in to comment.