]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Members.pm
Add the possibility to set your coordinates.
[ndwebbie.git] / lib / NDWeb / Controller / Members.pm
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;