]> ruin.nu Git - ndwebbie.git/blob - editRaid.pl
editRaid
[ndwebbie.git] / editRaid.pl
1 #**************************************************************************
2 #   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
3 #                                                                         *
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.                                   *
8 #                                                                         *
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.                          *
13 #                                                                         *
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 #**************************************************************************/
19
20 use strict;
21 use POSIX;
22 our $BODY;
23 our $DBH;
24 our $LOG;
25
26 $ND::TEMPLATE->param(TITLE => 'Create/Edit Raids');
27
28 die "You don't have access" unless isBC();
29
30 my @alliances = alliances();
31 $BODY->param(Alliances => \@alliances);
32
33 my $raid;
34 if (param('raid') =~ /^(\d+)$/){
35         my $query = $DBH->prepare(q{SELECT id,tick,waves,message,released_coords FROM raids WHERE id = ?});
36         $raid = $DBH->selectrow_hashref($query,undef,$1);
37 }
38
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->{id});
41
42 my @addgroups;
43 my @remgroups;
44 while (my $group = $groups->fetchrow_hashref){
45         if ($group->{raid}){
46                 push @remgroups,{Id => $group->{id}, Name => $group->{groupname}};
47         }else{
48                 push @addgroups,{Id => $group->{id}, Name => $group->{groupname}};
49         }
50 }
51 $BODY->param(RemoveGroups => \@remgroups);
52 $BODY->param(AddGroups => \@addgroups);
53
54 if ($raid){
55 }else{
56 }
57
58 1;