+++ /dev/null
-#**************************************************************************
-# 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::DefRequest;
-use strict;
-use warnings FATAL => 'all';
-use CGI qw/:standard/;
-use NDWeb::Include;
-
-use base qw/NDWeb::XMLPage/;
-
-$NDWeb::Page::PAGES{defrequest} = __PACKAGE__;
-
-sub render_body {
- my $self = shift;
- my ($BODY) = @_;
- $self->{TITLE} = 'Request Defense';
- my $DBH = $self->{DBH};
-
- return $self->noAccess unless $self->isMember;
-
- my $error;
-
- if (defined param('cmd') && param('cmd') eq 'submit'){
- my $insert = $DBH->prepare('INSERT INTO defense_requests (uid,message) VALUES (?,?)');
- if($insert->execute($ND::UID,param('message'))){
- $BODY->param(Reply => param('message'));
- }else{
- $error .= "<b>".$DBH->errstr."</b>";
- }
- }
- $BODY->param(Error => $error);
- return $BODY;
-}
-1;
--- /dev/null
+CREATE TABLE irc_requests (
+ id SERIAL PRIMARY KEY,
+ channel TEXT NOT NULL,
+ message TEXT NOT NULL,
+ sent BOOL NOT NULL DEFAULT FALSE,
+ uid INTEGER NOT NULL REFERENCES users(uid)
+);
$c->res->redirect($c->uri_for(''));
}
+sub ircrequest : Local {
+ my ( $self, $c ) = @_;
+ my $dbh = $c->model;
+
+ $c->stash(reply => $c->flash->{reply});
+ $c->stash(channels => ['def','scan','members']);
+}
+
+sub postircrequest : Local {
+ my ( $self, $c ) = @_;
+ my $dbh = $c->model;
+
+ my $query = $dbh->prepare(q{INSERT INTO irc_requests
+ (uid,channel,message) VALUES($1,$2,$3)
+ });
+ $query->execute($c->user->id,$c->req->param('channel'),$c->req->param('message'));
+
+ $c->flash(reply => "Msg sent to: ".$c->req->param('channel'));
+ $c->res->redirect($c->uri_for('ircrequest'));
+}
sub points : Local {
my ( $self, $c, $order ) = @_;
<li><a href="/members/launchConfirmation">Launch confirmation</a></li>
<li><a href="/covop">CovOp targets</a></li>
<li><a href="/covop/distwhores">Distwhores</a></li>
- <li><a href="/members/defrequest">Request defense</a></li>
+ <li><a href="/members/ircrequest">IRC request</a></li>
</ul>
[% ELSE %]
[% IF c.user.planet %]
--- /dev/null
+[% META title = 'IRC Request' %]
+[% IF reply %]
+<h3>[% reply %]</h3>
+[% END %]
+<form action="[% c.uri_for('postircrequest') %]" method="post"><fieldset> <legend>Launch confirmation</legend>
+ <p>Message to irc. To def channel you can report incs with a line from gal status.</p>
+ <select name="channel">
+[% FOR ch IN channels %]
+ <option value="[% ch %]">[% ch | ucfirst %]</option>
+[% END %]
+ </select>
+ <input type="text" name="message" value="">
+ <br><input type="submit" value="Send">
+</fieldset></form>
+++ /dev/null
-<TMPL_VAR NAME=Error>
-<TMPL_IF Reply><p>Sent the message '<TMPL_VAR NAME=Reply>' to def
-channel</p></TMPL_IF>
-<form action="<TMPL_VAR NAME=PAGE>" method="post"><fieldset> <legend>Launch confirmation</legend>
- <p>Message to def channel (like a line from gal status):</p>
- <input type="text" name="message" value=""/>
- <input type="hidden" name="cmd" value="submit"/>
- <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
- <br/>
- <input type="submit" value="Submit"/>
-</fieldset></form>