X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FMembers.pm;h=4e57477ef07f362308222869ec3894dd3e4078a2;hb=15e271f8e65bfc35d311f9b9cad581e3a1c70def;hp=8c44e056590cb0e5832c4ab3281c1f79a79b3a71;hpb=5b6c3c7d0003d636c1c3da6d25734e4aad5736a5;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Members.pm b/lib/NDWeb/Controller/Members.pm index 8c44e05..4e57477 100644 --- a/lib/NDWeb/Controller/Members.pm +++ b/lib/NDWeb/Controller/Members.pm @@ -32,7 +32,7 @@ sub index : Path : Args(0) { $c->stash(comma => \&comma_value); $c->stash(u => $dbh->selectrow_hashref(q{SELECT planet,defense_points ,attack_points,scan_points,humor_points - , (attack_points+defense_points+scan_points/20) as total_points + , (attack_points+defense_points+scan_points/20)::NUMERIC(5,1) as total_points , sms,rank,hostmask FROM users WHERE uid = ? },undef,$c->user->id) ); @@ -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; @@ -261,7 +285,7 @@ sub points : Local { my $query = $dbh->prepare(qq{SELECT username,defense_points,attack_points ,scan_points,humor_points - ,(attack_points+defense_points+scan_points/20) as total_points + ,(attack_points+defense_points+scan_points/20)::NUMERIC(4,0) as total_points , count(NULLIF(rc.launched,FALSE)) AS raid_points FROM users u LEFT OUTER JOIN raid_claims rc USING (uid) WHERE uid IN (SELECT uid FROM groupmembers WHERE gid = 2)