X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FMembers.pm;h=b8cdbe159d313858d6d1bf89a4dad5f8c883e139;hp=2f89142da1e7082ec467fb2fcf63661e03850454;hb=31684a2875d8b342c7007faa8f564de2f26dc14e;hpb=d6b15c14f164e7150ffcaed86e8aa79795b2d89a diff --git a/lib/NDWeb/Controller/Members.pm b/lib/NDWeb/Controller/Members.pm index 2f89142..b8cdbe1 100644 --- a/lib/NDWeb/Controller/Members.pm +++ b/lib/NDWeb/Controller/Members.pm @@ -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;