X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FStats.pm;h=36cc1e5ef19e1997415ff53a956537b8a17661ad;hb=eb3bda37d084c0e6b13c97f88f06d5563c40d2fb;hp=63ad6d781dc6828ac64b6296d9723d35114eaf66;hpb=a4b209407c81ec7b71c9c7f8c4d57bb2f77256f4;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Stats.pm b/lib/NDWeb/Controller/Stats.pm index 63ad6d7..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); @@ -210,6 +215,7 @@ sub find : Local { my $dbh = $c->model; local $_ = $find || $c->req->param('coords'); + $c->stash(searchterm => $_); if (/(\d+)(?: |:)(\d+)(?: |:)(\d+)(?:(?: |:)(\d+))?/){ my $planet = $dbh->selectrow_array(q{SELECT planetid($1,$2,$3,$4)} @@ -217,8 +223,19 @@ sub find : Local { $c->res->redirect($c->uri_for('planet',$planet)); }elsif (/(\d+)(?: |:)(\d+)/){ $c->res->redirect($c->uri_for('galaxy',$1,$2)); + }elsif($c->check_user_roles(qw/stats_find_nick/)) { + my $query = $dbh->prepare(q{SELECT id,coords(x,y,z),nick + FROM current_planet_stats p + WHERE nick ilike $1 + }); + $query->execute($_); + my $planets = $query->fetchall_arrayref({}); + if (@{$planets} == 1){ + $c->res->redirect($c->uri_for('planet',$planets->[0]->{id})); + }else{ + $c->stash(planets => $planets); + } } - }