From: Michael Andreen Date: Fri, 7 Nov 2008 13:28:43 +0000 (+0100) Subject: Added more status codes X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=28cc9c2d61cf6ee0bfcd02c82e0195efaf6cf27a Added more status codes --- diff --git a/lib/NDWeb/Controller/Forum.pm b/lib/NDWeb/Controller/Forum.pm index 1a79624..2de3ea8 100644 --- a/lib/NDWeb/Controller/Forum.pm +++ b/lib/NDWeb/Controller/Forum.pm @@ -159,6 +159,9 @@ sub board : Local { $c->forward('findBoard'); $board = $c->stash->{board}; + if ( !defined $board->{fbid}){ + $c->detach('/default'); + } my $threads = $dbh->prepare(q{SELECT ft.ftid,u.username,ft.subject ,count(NULLIF(COALESCE(fp.time > ftv.time,TRUE),FALSE)) AS unread,count(fp.fpid) AS posts @@ -180,6 +183,10 @@ sub board : Local { while (my $thread = $threads->fetchrow_hashref){ push @threads,$thread; } + + if ( !(defined $board->{post}) && @threads == 0){ + $c->acl_access_denied('test',$c->action,'No access to board') + } $c->stash(threads => \@threads); $c->forward('listModeratorBoards', [$board->{fbid}]) if $board->{moderate}; @@ -192,7 +199,8 @@ sub thread : Local { $c->forward('findThread'); unless ($c->stash->{thread}){ - $c->stash(template => 'access_denied.tt2'); + $c->stash(template => 'default.tt2'); + $c->res->status(404); return; } my $query = $dbh->prepare(q{SELECT uid,username FROM users u diff --git a/lib/NDWeb/Controller/Rankings.pm b/lib/NDWeb/Controller/Rankings.pm index 30407c6..1575d4e 100644 --- a/lib/NDWeb/Controller/Rankings.pm +++ b/lib/NDWeb/Controller/Rankings.pm @@ -36,6 +36,7 @@ sub planets : Local { my $error = ''; $offset = 0 unless $offset; + $c->detach('/default') if $offset < 0; $c->stash(offset => $offset); $c->stash( comma => \&comma_value); @@ -74,6 +75,7 @@ sub planets : Local { while (my $planet = $query->fetchrow_hashref){ push @planets,$planet; } + $c->detach('/default') unless @planets; $c->stash(planets => \@planets); } @@ -84,6 +86,7 @@ sub galaxies : Local { my $error = ''; $offset = 0 unless $offset; + $c->detach('/default') if $offset < 0; $c->stash(offset => $offset); $c->stash( comma => \&comma_value); @@ -118,6 +121,7 @@ sub galaxies : Local { while (my $galaxy = $query->fetchrow_hashref){ push @galaxies,$galaxy; } + $c->detach('/default') unless @galaxies; $c->stash(galaxies => \@galaxies); } @@ -129,6 +133,7 @@ sub alliances : Local { my $error = ''; $offset = 0 unless $offset; + $c->detach('/default') if $offset < 0; $c->stash(offset => $offset); $c->stash( comma => \&comma_value); @@ -170,6 +175,7 @@ sub alliances : Local { while (my $alliance = $query->fetchrow_hashref){ push @alliances,$alliance; } + $c->detach('/default') unless @alliances; $c->stash(alliances => \@alliances); } diff --git a/lib/NDWeb/Controller/Root.pm b/lib/NDWeb/Controller/Root.pm index fcff93f..9ce7f8c 100644 --- a/lib/NDWeb/Controller/Root.pm +++ b/lib/NDWeb/Controller/Root.pm @@ -38,7 +38,8 @@ sub index : Local Path Args(0) { sub default : Path { my ( $self, $c ) = @_; - $c->response->status(404); + $c->stash(template => 'default.tt2'); + $c->response->status(410); } sub login : Local { @@ -166,7 +167,7 @@ Attempt to render a view, if needed. sub end : ActionClass('RenderView') { my ($self, $c) = @_; - if ($c->res->status == 302){ + if ($c->res->status >= 300 && $c->res->status <= 400 ){ return; } diff --git a/lib/NDWeb/Controller/Stats.pm b/lib/NDWeb/Controller/Stats.pm index 1c52a02..36cc1e5 100644 --- a/lib/NDWeb/Controller/Stats.pm +++ b/lib/NDWeb/Controller/Stats.pm @@ -55,7 +55,10 @@ sub galaxy : Local { }); $query->execute($x,$y); - $c->stash(g => $query->fetchrow_hashref ); + my $g = $query->fetchrow_hashref; + $c->detach('/default') unless $g; + $c->stash(g => $g); + my $extra_columns = ''; if ($c->check_user_roles(qw/stats_intel/)){ @@ -102,6 +105,8 @@ sub planet : Local { my $p = $dbh->selectrow_hashref(q{SELECT id,x,y,z FROM current_planet_stats WHERE id = $1},undef,$id); + $c->detach('/default') unless $p; + $c->forward('galaxy',[$p->{x},$p->{y},$p->{z}]); $c->stash(p => $p); diff --git a/root/src/rankings/alliances.tt2 b/root/src/rankings/alliances.tt2 index 1a6cb21..6e5e89b 100644 --- a/root/src/rankings/alliances.tt2 +++ b/root/src/rankings/alliances.tt2 @@ -1,6 +1,6 @@ [% META title = 'Alliance Rankings' %]

[% IF offset > 0 %]Previous 100[% END %] - [% IF alliances.size > 0 %]Next 100[% END %] + [% IF alliances.size == 100 %]Next 100[% END %]

@@ -36,5 +36,5 @@ [% END %]
Rank

[% IF offset > 0 %]Previous 100[% END %] - [% IF alliances.size > 0 %]Next 100[% END %] + [% IF alliances.size == 100 %]Next 100[% END %]

diff --git a/root/src/rankings/galaxies.tt2 b/root/src/rankings/galaxies.tt2 index adfa587..5b96de2 100644 --- a/root/src/rankings/galaxies.tt2 +++ b/root/src/rankings/galaxies.tt2 @@ -1,6 +1,6 @@ [% META title = 'Galaxy Rankings' %]

[% IF offset > 0 %]Previous 100[% END %] - [% IF galaxies.size > 0 %]Next 100[% END %] + [% IF galaxies.size == 100 %]Next 100[% END %]

@@ -42,5 +42,5 @@ [% END %]
Rank

[% IF offset > 0 %]Previous 100[% END %] - [% IF galaxies.size > 0 %]Next 100[% END %] + [% IF galaxies.size == 100 %]Next 100[% END %]

diff --git a/root/src/rankings/planets.tt2 b/root/src/rankings/planets.tt2 index 1ddf59a..b55b625 100644 --- a/root/src/rankings/planets.tt2 +++ b/root/src/rankings/planets.tt2 @@ -1,6 +1,6 @@ [% META title = 'Planet Rankings' %]

[% IF offset > 0 %]Previous 100[% END %] - [% IF planets.size > 0 %]Next 100[% END %] + [% IF planets.size == 100 %]Next 100[% END %]

@@ -55,5 +55,5 @@ [% END %]
Rank

[% IF offset > 0 %]Previous 100[% END %] - [% IF planets.size > 0 %]Next 100[% END %] + [% IF planets.size == 100 %]Next 100[% END %]