1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
26 $ND::TEMPLATE->param(TITLE => 'Create/Edit Raids');
28 die "You don't have access" unless isBC();
30 my @alliances = alliances();
31 $BODY->param(Alliances => \@alliances);
34 if (param('raid') =~ /^(\d+)$/){
35 my $query = $DBH->prepare(q{SELECT id,tick,waves,message,released_coords,open FROM raids WHERE id = ?});
36 $raid = $DBH->selectrow_hashref($query,undef,$1);
39 my $groups = $DBH->prepare(q{SELECT g.gid,g.groupname,raid FROM groups g LEFT OUTER JOIN (SELECT gid,raid FROM raid_access WHERE raid = ?) AS ra ON g.gid = ra.gid WHERE g.attack});
40 $groups->execute($raid ? $raid->{id} : undef);
44 while (my $group = $groups->fetchrow_hashref){
46 push @remgroups,{Id => $group->{gid}, Name => $group->{groupname}};
48 push @addgroups,{Id => $group->{gid}, Name => $group->{groupname}};
51 $BODY->param(RemoveGroups => \@remgroups);
52 $BODY->param(AddGroups => \@addgroups);
55 $BODY->param(Raid => $raid->{id});
57 $BODY->param(Open => 'Open');
59 $BODY->param(Open => 'Close');
61 if($raid->{released_coords}){
62 $BODY->param(ShowCoords => 'hidecoords');
63 $BODY->param(ShowCoordsName => 'Hide');
65 $BODY->param(ShowCoords => 'showcoords');
66 $BODY->param(ShowCoordsName => 'Show');
68 $BODY->param(Waves => $raid->{waves});
69 $BODY->param(LandingTick => $raid->{tick});
70 $BODY->param(Message => $raid->{message});
72 my $order = "p.x,p.y,p.z";
73 if (param('order') =~ /^(score|size|value|xp|race)$/){
77 my $targetquery = $DBH->prepare(qq{SELECT p.id,coords(x,y,z),raid,comment,size,score,value,race,planet_status AS planetstatus,relationship,comment
78 FROM current_planet_stats p JOIN raid_targets r ON p.id = r.planet
79 LEFT OUTER JOIN covop_targets c ON p.id = c.planet
82 $targetquery->execute($raid->{id}) or print $DBH->errstr;
84 while (my $target = $targetquery->fetchrow_hashref){
85 push @targets,$target;
87 $BODY->param(Targets => \@targets);
89 $BODY->param(Waves => 3);
90 $BODY->param(LandingTick => $ND::TICK+12);