# Free Software Foundation, Inc., *
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
#**************************************************************************/
-package ND::Web::Pages::EditRaid;
+package NDWeb::Pages::EditRaid;
use strict;
use warnings FATAL => 'all';
use ND::Include;
use CGI qw/:standard/;
-use ND::Web::Include;
+use NDWeb::Include;
-use base qw/ND::Web::XMLPage/;
+use base qw/NDWeb::XMLPage/;
-$ND::Web::Page::PAGES{editRaid} = __PACKAGE__;
+$NDWeb::Page::PAGES{editRaid} = __PACKAGE__;
sub render_body {
my $self = shift;
my $comment = $DBH->prepare(q{UPDATE raid_targets SET comment = ? WHERE id = ?});
my $unclaim = $DBH->prepare(q{DELETE FROM raid_claims WHERE target = ? AND wave = ?});
my $block = $DBH->prepare(q{INSERT INTO raid_claims (target,uid,wave) VALUES(?,-2,?)});
+ my $claim = $DBH->prepare(q{INSERT INTO raid_claims (target,uid,wave)
+ VALUES($1,(SELECT uid FROM users WHERE username ILIKE $3),$2)
+ });
+ my $unblock = $DBH->prepare(q{DELETE FROM raid_claims WHERE target = ? AND wave = ? AND uid = -2});
my $remove = $DBH->prepare(q{DELETE FROM raid_targets WHERE raid = ? AND id = ?});
for $_ (param()){
if (/^comment:(\d+)$/){
log_message $ND::UID,"BC unclaimed target $1 wave $2.";
}elsif(/^block:(\d+):(\d+)$/){
$block->execute($1,$2) or $error .= p($DBH->errstr);
+ }elsif(/^claim:(\d+):(\d+)$/){
+ my $target = $1;
+ my $wave = $2;
+ my @claims = split /[, ]+/, param($_);
+ $unblock->execute($target,$wave) if @claims;
+ for (@claims){
+ $claim->execute($target,$wave,$_) or warn $DBH->errstr;
+ }
}elsif(/^remove:(\d+)$/){
$remove->execute($raid->{id},$1) or $error .= p($DBH->errstr);
}
}
$target->{waves} = \@waves;
- my $scans = $DBH->prepare(q{SELECT DISTINCT ON (type) type, tick, scan FROM scans
- WHERE planet = ? AND type ~ 'Unit|Planet|Advanced Unit|.* Analysis' AND tick + 24 > tick() AND scan is not null
- GROUP BY type, tick, scan ORDER BY type ,tick DESC});
+ my $scans = $DBH->prepare(q{SELECT DISTINCT ON (type) scan_id,type, tick FROM scans
+ WHERE planet = ? AND type ~ 'Unit|Planet|Advanced Unit|.* Analysis' AND tick + 24 > tick()
+ ORDER BY type ,tick DESC});
$scans->execute($target->{planet});
delete $target->{planet};
- my %scans;
- while (my $scan = $scans->fetchrow_hashref){
- $scans{$scan->{type}} = $scan;
- }
my @scans;
- for my $type ('Planet','Unit','Advanced Unit','Surface Analysis','Technology Analysis'){
- next unless exists $scans{$type};
- my $scan = $scans{$type};
- if ($self->{TICK} - $scan->{tick} > 5){
- $scan->{scan} =~ s{<table( cellpadding="\d+")?>}{<table class="old">};
- }
- if ($type eq 'Planet'){
- $target->{PlanetScan} = $scan->{scan};
- next;
- }
- push @scans,{Scan => $scan->{scan}};
+ while (my $scan = $scans->fetchrow_hashref){
+ push @scans,$scan;
}
$target->{Scans} = \@scans;
push @targets,$target;