X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FMembers.pm;h=4e57477ef07f362308222869ec3894dd3e4078a2;hb=15e271f8e65bfc35d311f9b9cad581e3a1c70def;hp=bb1f741bd39505f458d5ead5cb6d04f798b9f489;hpb=f79954caa064990f19788089b412b502369675de;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Members.pm b/lib/NDWeb/Controller/Members.pm index bb1f741..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; @@ -250,7 +274,7 @@ sub points : Local { my ( $self, $c, $order ) = @_; my $dbh = $c->model; - if ($order =~ /^((?:defense|attack|total|humor|scan|raid)_points)$/){ + if ($order && $order =~ /^((?:defense|attack|total|humor|scan|raid)_points)$/){ $order = "$1 DESC"; }else{ $order = 'total_points DESC'; @@ -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) @@ -417,7 +441,7 @@ sub postconfirmation : Local { }); my @missions; $dbh->begin_work; - while ($missions =~ m/([^\n]+)\s+(\d+):(\d+):(\d+)\s+(\d+):(\d+):(\d+) + while ($missions && $missions =~ m/([^\n]+)\s+(\d+):(\d+):(\d+)\s+(\d+):(\d+):(\d+) \s+\((?:(\d+)\+)?(\d+)\).*?(?:\d+hrs\s+)?\d+mins?\s+ (Attack|Defend|Return|Fake\ Attack|Fake\ Defend) (.*?)