]> ruin.nu Git - ndwebbie.git/commitdiff
Converted naps page
authorMichael Andreen <harv@ruin.nu>
Fri, 18 Jul 2008 22:30:23 +0000 (00:30 +0200)
committerMichael Andreen <harv@ruin.nu>
Fri, 18 Jul 2008 22:30:23 +0000 (00:30 +0200)
NDWeb/Pages/PlanetNaps.pm [deleted file]
database/group_roles.sql
lib/NDWeb.pm
lib/NDWeb/Controller/Intel.pm
root/lib/site/leftbar.tt2
root/src/intel/naps.tt2 [new file with mode: 0644]
templates/planetNaps.tmpl [deleted file]

diff --git a/NDWeb/Pages/PlanetNaps.pm b/NDWeb/Pages/PlanetNaps.pm
deleted file mode 100644 (file)
index adcd5b7..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#**************************************************************************
-#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
-#                                                                         *
-#   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;
index 75477153cfd084f80e7a64309c0d9e61ef9ed5c7..add205fc90bac0c79a3593764d4b47b9490aaaa8 100644 (file)
@@ -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');
index 7e3a63be16c58f128be2af85481358d3d32e29f1..4bbf61dd5ed150ba8970c6974bec4c125856dcf0 100644 (file)
@@ -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
 
index 46fe6ce79deaa147f0e326e6904489c5e2a5d69e..0a683c0618a57caa1fbbace638eee97660ec652d 100644 (file)
@@ -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
 
index 73f7b013a373074739a49a452b41ab2e2bb1d59b..9e250e52b83fb484f34f39044725b251a6fd3fbb 100644 (file)
        <li><a href="/alliances/hostile">Hostile Alliances</a></li>
        <li><a href="/intel/members">Member Intel</a></li>
        <li><a href="/alliances/resources">Alliance resources</a></li>
-       <li><a href="/planetNaps">Planet Naps</a></li>
+       <li><a href="/intel/naps">Planet Naps</a></li>
        <li><a href="/users/mail">Mail</a></li>
 </ul>
 [% END %]
diff --git a/root/src/intel/naps.tt2 b/root/src/intel/naps.tt2
new file mode 100644 (file)
index 0000000..064dfc5
--- /dev/null
@@ -0,0 +1,21 @@
+[% META title = 'Planet NAPs' %]
+<table>
+       <tr><th>Coords</th><th>Planet</th><th>Race</th><th>Size (rank)</th><th>Score (rank)</th><th>Value (rank)</th>
+               <th>XP (rank)</th><th>Fleet (Resouce) value</th><th>Nick</th><th>Hit us</th><th>Alliance</th>
+       </tr>
+[% FOR p IN planets %]
+       <tr align="center"  class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
+               <td><a href="[% c.uri_for('/stats/planet',p.id) %]">[% p.coords %]</a></td>
+               <td>[% p.ruler %] <b>OF</b> [% p.planet %]</td>
+               <td>[% p.race %]</td>
+               <td>[% p.size %] ([% p.sizerank %])</td>
+               <td>[% p.score %] ([% p.scorerank %])</td>
+               <td>[% p.value %] ([% p.valuerank %])</td>
+               <td>[% p.xp %] ([% p.xprank %])</td>
+               <td>[% p.fleetvalue %] ([% p.resvalue %])</td>
+               <td class="[% p.planet_status %]"><a href="[% c.uri_for('planet',p.id) %]">[% p.nick %]([% p.planet_status %])</a></td>
+               <td>[% p.hit_us %]</td>
+               <td class="[% p.relationship %]">[% p.alliance %]</td>
+       </tr>
+[% END %]
+</table>
diff --git a/templates/planetNaps.tmpl b/templates/planetNaps.tmpl
deleted file mode 100644 (file)
index e1f99d0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<TMPL_VAR NAME=Error>
-<!--<TMPL_VAR NAME=PAGE>-->
-<table>
-       <tr><th>Coords</th><th>Planet</th><th>Race</th><th>Size (rank)</th><th>Score (rank)</th><th>Value (rank)</th>
-               <th>XP (rank)</th><th>Fleet (Resouce) value</th><th>Nick</th><th>Hit us</th><th>Alliance</th>
-       </tr>
-       <TMPL_LOOP Planets>
-       <tr align="center"  class="<TMPL_IF __odd__>odd<TMPL_ELSE>even</TMPL_IF>">
-               <td><a href="check?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords></a></td>
-               <td><TMPL_VAR NAME=Planet></td><td><TMPL_VAR NAME=Race></td>
-               <td><TMPL_VAR NAME=Size>(<TMPL_VAR NAME=Sizerank>)</td>
-               <td><TMPL_VAR NAME=Score>(<TMPL_VAR NAME=Scorerank>)</td>
-               <td><TMPL_VAR NAME=Value>(<TMPL_VAR NAME=Valuerank>)</td>
-               <td><TMPL_VAR NAME=XP>(<TMPL_VAR NAME=XPrank>)</td>
-               <td><TMPL_VAR NAME=FleetValue> (<TMPL_VAR NAME=ResValue>)</td>
-               <td class="<TMPL_VAR NAME=Planet_Status>"><a href="intel?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Nick>(<TMPL_VAR NAME=Planet_Status>)</a></td>
-               <td><TMPL_VAR NAME=Hit_Us></td>
-               <td class="<TMPL_VAR NAME=Relationship>"><TMPL_VAR NAME=Alliance></td>
-       </tr>
-
-       </TMPL_LOOP>
-</table>