X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND%2FWeb%2FPages%2FAlliances.pm;h=69d7c92594695bfbaa6fe88e15ad3e5f34045120;hb=c6a6e6dbab0ca435e6aeeb94e7c7329585b7b4f1;hp=aec9ea4a1cf5de17249d5add64fcc6028bdc9016;hpb=9ce5a8529e75cb109ed9ba3fc788c94ef47b1080;p=ndwebbie.git diff --git a/ND/Web/Pages/Alliances.pm b/ND/Web/Pages/Alliances.pm index aec9ea4..69d7c92 100644 --- a/ND/Web/Pages/Alliances.pm +++ b/ND/Web/Pages/Alliances.pm @@ -24,23 +24,18 @@ use ND::Include; use CGI qw/:standard/; use ND::Web::Include; -$ND::PAGES{alliances} = {parse => \&parse, process => \&process, render=> \&render}; +use base qw/ND::Web::XMLPage/; -sub parse { - my ($uri) = @_; -} - -sub process { +$ND::Web::Page::PAGES{alliances} = __PACKAGE__; -} - -sub render { - my ($DBH,$BODY) = @_; +sub render_body { + my $self = shift; + my ($BODY) = @_; + $self->{TITLE} = 'Alliances'; + my $DBH = $self->{DBH}; my $error; - $ND::TEMPLATE->param(TITLE => 'Alliances'); - - return $ND::NOACCESS unless isHC(); + return $self->noAccess unless $self->isHC; my $alliance; if (defined param('alliance') && param('alliance') =~ /^(\d+)$/){ @@ -108,12 +103,12 @@ sub render { } $BODY->param(Members => \@members); - my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',qq{not ingal AND (t.alliance_id = ? OR t.alliance_id = ?) + my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',q{not ingal AND (o.alliance_id = $1 OR t.alliance_id = $1) AND (i.mission = 'Defend' OR i.mission = 'AllyDef') - AND (t.alliance_id != ? OR t.alliance_id IS NULL OR o.alliance_id != ? OR o.alliance_id IS NULL) + AND ((( t.alliance_id != o.alliance_id OR t.alliance_id IS NULL OR o.alliance_id IS NULL))) AND i.sender NOT IN (SELECT planet FROM users u NATURAL JOIN groupmembers gm WHERE gid = 8 AND planet IS NOT NULL) })); - $query->execute($alliance->{id},$alliance->{id},$alliance->{id},$alliance->{id}) or $error .= $DBH->errstr; + $query->execute($alliance->{id}) or $error .= $DBH->errstr; my @intel; $i = 0; @@ -135,7 +130,7 @@ sub render { $order = "$1 DESC"; } my $query = $DBH->prepare(qq{ - SELECT DISTINCT a.id,name,COALESCE(s.score,SUM(p.score)) AS score,COALESCE(s.size,SUM(p.size)) AS size,s.members,count(*) AS kmem, + SELECT DISTINCT a.id,name,COALESCE(s.score,SUM(p.score)) AS score,COALESCE(s.size,SUM(p.size)) AS size,s.members,count(p.score) AS kmem, COALESCE(SUM(p.score),-1) AS kscore, COALESCE(SUM(p.size),-1) AS ksize, COALESCE(SUM(p.xp),-1) AS kxp,COALESCE(SUM(p.value),-1) AS kvalue, COALESCE(s.score/LEAST(s.members,60),-1) AS scavg, COALESCE(AVG(p.score)::int,-1) AS kscavg, COALESCE(s.size/s.members,-1) AS siavg, COALESCE(AVG(p.size)::int,-1) AS ksiavg, COALESCE(AVG(p.xp)::int,-1) AS kxpavg, COALESCE(AVG(p.value)::int,-1) AS kvalavg