]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Members.pm
Shipname can contain space now
[ndwebbie.git] / lib / NDWeb / Controller / Members.pm
index 2ed177f9d717a179c983967c2fb6d0cdddb95e85..65b1355ae23f20f599a7ec1f183d4295fda87f0f 100644 (file)
@@ -83,6 +83,12 @@ ORDER BY landing_tick DESC
                });
        $announcements->execute($c->user->id);
        $c->stash(announcements => $announcements->fetchall_arrayref({}) );
+
+       my ($attackgroups) = $dbh->selectrow_array(q{
+SELECT array_agg(gid) FROM groupmembers WHERE gid IN ('x','y','z') AND uid = $1
+               }, undef, $c->user->id);
+       $c->stash(attackgroups => $attackgroups);
+
 }
 
 sub posthostupdate : Local {
@@ -95,6 +101,23 @@ sub posthostupdate : Local {
        $c->res->redirect($c->uri_for(''));
 }
 
+sub postattackgroups : Local {
+       my ( $self, $c ) = @_;
+       my $dbh = $c->model;
+
+       my @groups = $c->req->param('class');
+       $dbh->do(q{DELETE FROM groupmembers WHERE gid IN ('x','y','z') AND gid <> ALL($1) AND uid = $2
+               },undef, \@groups, $c->user->id);
+
+       $dbh->do(q{INSERT INTO groupmembers (uid,gid) (
+               SELECT $2, gid FROM unnest($1::text[]) AS gid WHERE gid IN ('x','y','z')
+       EXCEPT
+               SELECT uid,gid FROM groupmembers WHERE uid = $2
+               )},undef, \@groups, $c->user->id);
+
+       $c->res->redirect($c->uri_for(''));
+}
+
 sub postsmsupdate : Local {
        my ( $self, $c ) = @_;
        my $dbh = $c->model;
@@ -605,7 +628,6 @@ sub parseconfirmations {
                        }
 
                        given(shift @etas){
-                               $mission{name} .= " $_";
                                when(/$missionetare/sx){
                                        $mission{tick} = $3;
                                        $mission{eta} = $1 + $+{eta};
@@ -634,7 +656,7 @@ sub parseconfirmations {
                        amount => 0,
                        ships => []
                };
-               while ($match{ships}->[0] =~ m/(\w+)\s+(FI|CO|FR|DE|CR|BS)[^\d]+((?:\d+\s*){5})/g){
+               while ($match{ships}->[0] =~ m/(\w[ \w]+?)\s+(FI|CO|FR|DE|CR|BS)[^\d]+((?:\d+\s*){5})/g){
                        my $ship = $1;
                        my @amounts = split /\D+/, $3;
                        my $base = shift @amounts;