]> ruin.nu Git - ndwebbie.git/commitdiff
Add the possibility to set your coordinates.
authorMichael Andreen <harv@ruin.nu>
Sun, 10 Aug 2008 12:32:11 +0000 (14:32 +0200)
committerMichael Andreen <harv@ruin.nu>
Sun, 10 Aug 2008 12:32:11 +0000 (14:32 +0200)
lib/NDWeb/Controller/Members.pm
root/lib/site/leftbar.tt2

index 8c44e056590cb0e5832c4ab3281c1f79a79b3a71..bb31b694b6484b96cdca34a533bf148eb4ed5b13 100644 (file)
@@ -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;
index c5c71b270f8f3afa4d921697e6ca65d4fb405b1c..ff9a0848c36ac84f06554ed4ca6f3200dc993252 100644 (file)
@@ -46,7 +46,7 @@
                [% IF c.user.planet %]
        <p><b>Update your fleet to see member menu</b></p>
                [% ELSE %]
-       <form action="/members/setcoords" method="post">
+       <form action="/members/postowncoords" method="post">
                <p>We need your planet's coordinates: 
                <input type="text" name="planet" value="">
                <input type="submit" value="Submit">