From 492509a0eb89744961a1d40c25ffdd3b645910d3 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 19 Jul 2008 00:30:23 +0200 Subject: [PATCH] Converted naps page --- NDWeb/Pages/PlanetNaps.pm | 61 ----------------------------------- database/group_roles.sql | 3 ++ lib/NDWeb.pm | 1 + lib/NDWeb/Controller/Intel.pm | 20 ++++++++++++ root/lib/site/leftbar.tt2 | 2 +- root/src/intel/naps.tt2 | 21 ++++++++++++ templates/planetNaps.tmpl | 22 ------------- 7 files changed, 46 insertions(+), 84 deletions(-) delete mode 100644 NDWeb/Pages/PlanetNaps.pm create mode 100644 root/src/intel/naps.tt2 delete mode 100644 templates/planetNaps.tmpl diff --git a/NDWeb/Pages/PlanetNaps.pm b/NDWeb/Pages/PlanetNaps.pm deleted file mode 100644 index adcd5b7..0000000 --- a/NDWeb/Pages/PlanetNaps.pm +++ /dev/null @@ -1,61 +0,0 @@ -#************************************************************************** -# Copyright (C) 2006 by Michael Andreen * -# * -# This program is free software; you can redistribute it and/or modify * -# it under the terms of the GNU General Public License as published by * -# the Free Software Foundation; either version 2 of the License, or * -# (at your option) any later version. * -# * -# This program is distributed in the hope that it will be useful, * -# but WITHOUT ANY WARRANTY; without even the implied warranty of * -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -# GNU General Public License for more details. * -# * -# You should have received a copy of the GNU General Public License * -# along with this program; if not, write to the * -# Free Software Foundation, Inc., * -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -#**************************************************************************/ - -package NDWeb::Pages::PlanetNaps; -use strict; -use warnings FATAL => 'all'; -use CGI qw/:standard/; -use NDWeb::Include; - -use base qw/NDWeb::XMLPage/; - -$NDWeb::Page::PAGES{planetNaps} = __PACKAGE__; - -sub render_body { - my $self = shift; - my ($BODY) = @_; - $self->{TITLE} = 'List planet naps'; - my $DBH = $self->{DBH}; - - return $self->noAccess unless $self->isHC; - my $error; - - my $query = $DBH->prepare(q{SELECT coords(x,y,z) - , ((ruler || ' OF ') || p.planet) AS planet,race, size, score, value - , xp, sizerank, scorerank, valuerank, xprank, p.value - p.size*200 - - COALESCE(ps.metal+ps.crystal+ps.eonium,0)/150 - - COALESCE(ss.total ,(SELECT COALESCE(avg(total),0) FROM structure_scans)::int)*1500 AS fleetvalue - ,(metal+crystal+eonium)/100 AS resvalue, planet_status,hit_us - , alliance,relationship,nick - FROM current_planet_stats p - LEFT OUTER JOIN planet_scans ps ON p.id = ps.planet - LEFT OUTER JOIN structure_scans ss ON p.id = ss.planet - WHERE planet_status IN ('Friendly','NAP') order by x,y,z asc}); - - $query->execute or $error .= p($DBH->errstr); - my @planets; - while (my $planet = $query->fetchrow_hashref){ - push @planets,$planet; - } - $BODY->param(Planets => \@planets); - $BODY->param(Error => $error); - return $BODY; -} - -1; diff --git a/database/group_roles.sql b/database/group_roles.sql index 7547715..add205f 100644 --- a/database/group_roles.sql +++ b/database/group_roles.sql @@ -36,6 +36,7 @@ INSERT INTO roles VALUES('stats_planetdata'); INSERT INTO roles VALUES('intel'); INSERT INTO roles VALUES('intel_members'); INSERT INTO roles VALUES('intel_member'); +INSERT INTO roles VALUES('intel_naps'); INSERT INTO group_roles (gid,role) VALUES(2,'member_menu'); INSERT INTO group_roles (gid,role) VALUES(2,'attack_menu'); @@ -80,6 +81,7 @@ INSERT INTO group_roles (gid,role) VALUES(1,'raids_edit'); INSERT INTO group_roles (gid,role) VALUES(1,'intel'); INSERT INTO group_roles (gid,role) VALUES(1,'intel_members'); INSERT INTO group_roles (gid,role) VALUES(1,'intel_member'); +INSERT INTO group_roles (gid,role) VALUES(1,'intel_naps'); INSERT INTO group_roles (gid,role) VALUES(3,'dc_menu'); INSERT INTO group_roles (gid,role) VALUES(3,'bc_menu'); @@ -98,3 +100,4 @@ INSERT INTO group_roles (gid,role) VALUES(3,'raids_edit'); INSERT INTO group_roles (gid,role) VALUES(3,'intel'); INSERT INTO group_roles (gid,role) VALUES(3,'intel_members'); INSERT INTO group_roles (gid,role) VALUES(3,'intel_member'); +INSERT INTO group_roles (gid,role) VALUES(3,'intel_naps'); diff --git a/lib/NDWeb.pm b/lib/NDWeb.pm index 7e3a63b..4bbf61d 100644 --- a/lib/NDWeb.pm +++ b/lib/NDWeb.pm @@ -90,6 +90,7 @@ __PACKAGE__->allow_access_if('/raids/log',1); __PACKAGE__->deny_access_unless('/intel',[qw/intel/]); __PACKAGE__->deny_access_unless('/intel/members',[qw/intel_members/]); __PACKAGE__->deny_access_unless('/intel/member',[qw/intel_member/]); +__PACKAGE__->deny_access_unless('/intel/naps',[qw/intel_naps/]); =head1 NAME diff --git a/lib/NDWeb/Controller/Intel.pm b/lib/NDWeb/Controller/Intel.pm index 46fe6ce..0a683c0 100644 --- a/lib/NDWeb/Controller/Intel.pm +++ b/lib/NDWeb/Controller/Intel.pm @@ -281,6 +281,26 @@ sub member : Local { $c->stash(defenses => \@defenses); } +sub naps : Local { + my ( $self, $c ) = @_; + my $dbh = $c->model; + + my $query = $dbh->prepare(q{SELECT p.id,coords(x,y,z) + ,ruler, p.planet,race, size, score, value + , xp, sizerank, scorerank, valuerank, xprank, p.value - p.size*200 + - COALESCE(ps.metal+ps.crystal+ps.eonium,0)/150 + - COALESCE(ss.total ,(SELECT COALESCE(avg(total),0) + FROM structure_scans)::int)*1500 AS fleetvalue + ,(metal+crystal+eonium)/100 AS resvalue, planet_status,hit_us + , alliance,relationship,nick + FROM current_planet_stats p + LEFT OUTER JOIN planet_scans ps ON p.id = ps.planet + LEFT OUTER JOIN structure_scans ss ON p.id = ss.planet + WHERE planet_status IN ('Friendly','NAP') order by x,y,z asc + }); + $query->execute; + $c->stash(planets => $query->fetchall_arrayref({}) ); +} =head1 AUTHOR diff --git a/root/lib/site/leftbar.tt2 b/root/lib/site/leftbar.tt2 index 73f7b01..9e250e5 100644 --- a/root/lib/site/leftbar.tt2 +++ b/root/lib/site/leftbar.tt2 @@ -100,7 +100,7 @@
  • Hostile Alliances
  • Member Intel
  • Alliance resources
  • -
  • Planet Naps
  • +
  • Planet Naps
  • Mail
  • [% END %] diff --git a/root/src/intel/naps.tt2 b/root/src/intel/naps.tt2 new file mode 100644 index 0000000..064dfc5 --- /dev/null +++ b/root/src/intel/naps.tt2 @@ -0,0 +1,21 @@ +[% META title = 'Planet NAPs' %] + + + + +[% FOR p IN planets %] + + + + + + + + + + + + + +[% END %] +
    CoordsPlanetRaceSize (rank)Score (rank)Value (rank)XP (rank)Fleet (Resouce) valueNickHit usAlliance
    [% p.coords %][% p.ruler %] OF [% p.planet %][% p.race %][% p.size %] ([% p.sizerank %])[% p.score %] ([% p.scorerank %])[% p.value %] ([% p.valuerank %])[% p.xp %] ([% p.xprank %])[% p.fleetvalue %] ([% p.resvalue %])[% p.nick %]([% p.planet_status %])[% p.hit_us %][% p.alliance %]
    diff --git a/templates/planetNaps.tmpl b/templates/planetNaps.tmpl deleted file mode 100644 index e1f99d0..0000000 --- a/templates/planetNaps.tmpl +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -
    CoordsPlanetRaceSize (rank)Score (rank)Value (rank)XP (rank)Fleet (Resouce) valueNickHit usAlliance
    ()()()() ()()
    -- 2.39.2