1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
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. *
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. *
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 package ND::Web::Page;
22 use CGI qw/:standard/;
28 my $class = ref($invocant) || $invocant;
30 $self->{PAGE} = 'main' unless (defined $self->{PAGE} and exists $PAGES{$self->{PAGE}});
31 $class = $PAGES{$self->{PAGE}};
38 sub initiate : method {
40 my $DBH = $self->{DBH};
42 $DBH->do(q{SET timezone = 'GMT'});
44 ($self->{UID},$self->{PLANET},$self->{USER}) = $DBH->selectrow_array('SELECT uid,planet,username FROM users WHERE username ILIKE ?'
45 ,undef,$ENV{'REMOTE_USER'});
46 $ND::UID = $self->{UID};
48 ($self->{TICK}) = $DBH->selectrow_array('SELECT tick()',undef);
49 $self->{TICK} = 0 unless defined $self->{TICK};
52 my $query = $DBH->prepare('SELECT groupname,attack,gid from groupmembers NATURAL JOIN groups WHERE uid = ?');
53 $query->execute($self->{UID});
55 while (my ($name,$attack,$gid) = $query->fetchrow()){
56 $self->{GROUPS}{$name} = $gid;
57 $self->{ATTACKER} = 1 if $attack;
66 sub render_body : method {
74 print $self->render_body;
77 sub isInGroup ($) : method {
80 return exists $self->{GROUPS}{$group} || exists $self->{GROUPS}{Tech} || exists $self->{GROUPS}{HC};
83 sub isMember () : method {
85 $self->isInGroup('Members');
88 sub isHC () : method {
90 $self->isInGroup('HC');
93 sub isDC () : method {
94 $_[0]->isInGroup('DC');
97 sub isBC () : method {
98 $_[0]->isInGroup('BC');
101 sub isOfficer () : method {
102 $_[0]->isInGroup('Officers');
105 sub isScanner () : method {
106 $_[0]->isInGroup('Scanners');
109 sub isIntel () : method {
110 $_[0]->isInGroup('Intel');
113 sub isTech () : method {
114 $_[0]->isInGroup('Tech');