From: Michael Andreen Date: Sun, 10 Aug 2008 12:32:11 +0000 (+0200) Subject: Add the possibility to set your coordinates. X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=49d3f8fb2b3bcf25f88d909e7982b20f1db3246d Add the possibility to set your coordinates. --- diff --git a/lib/NDWeb/Controller/Members.pm b/lib/NDWeb/Controller/Members.pm index 8c44e05..bb31b69 100644 --- a/lib/NDWeb/Controller/Members.pm +++ b/lib/NDWeb/Controller/Members.pm @@ -145,6 +145,30 @@ sub postsmsupdate : Local { $c->res->redirect($c->uri_for('')); } +sub postowncoords : Local { + my ( $self, $c ) = @_; + my $dbh = $c->model; + + if ($c->user->planet){ + $c->flash(error => 'You already have a planet set.' + .' Contact a HC if they need to be changed'); + }elsif ($c->req->param('planet') =~ m/(\d+)\D+(\d+)\D+(\d+)/){ + my $planet = $dbh->selectrow_array(q{SELECT planetid($1,$2,$3,TICK()) + },undef,$1,$2,$3); + + if ($planet){ + $dbh->do(q{UPDATE users SET planet = ? WHERE uid = ? + },undef, $planet , $c->user->id); + }else{ + $c->flash(error => "No planet at coords: $1:$2:$3"); + } + }else{ + $c->flash(error => $c->req->param('planet') . " are not valid coords."); + } + + $c->res->redirect($c->uri_for('')); +} + sub postfleetupdate : Local { my ( $self, $c ) = @_; my $dbh = $c->model; diff --git a/root/lib/site/leftbar.tt2 b/root/lib/site/leftbar.tt2 index c5c71b2..ff9a084 100644 --- a/root/lib/site/leftbar.tt2 +++ b/root/lib/site/leftbar.tt2 @@ -46,7 +46,7 @@ [% IF c.user.planet %]

Update your fleet to see member menu

[% ELSE %] -
+

We need your planet's coordinates: