]> ruin.nu Git - ndwebbie.git/commitdiff
Converted defrequest and made it into a generic irc request
authorMichael Andreen <harv@ruin.nu>
Wed, 16 Jul 2008 16:56:43 +0000 (18:56 +0200)
committerMichael Andreen <harv@ruin.nu>
Wed, 16 Jul 2008 16:56:43 +0000 (18:56 +0200)
NDWeb/Pages/DefRequest.pm [deleted file]
database/ircrequest.sql [new file with mode: 0644]
lib/NDWeb/Controller/Members.pm
root/lib/site/leftbar.tt2
root/src/members/ircrequest.tt2 [new file with mode: 0644]
templates/defrequest.tmpl [deleted file]

diff --git a/NDWeb/Pages/DefRequest.pm b/NDWeb/Pages/DefRequest.pm
deleted file mode 100644 (file)
index b8cec31..0000000
+++ /dev/null
@@ -1,51 +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::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;
diff --git a/database/ircrequest.sql b/database/ircrequest.sql
new file mode 100644 (file)
index 0000000..88abeff
--- /dev/null
@@ -0,0 +1,7 @@
+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)
+);
index 9373b8f58b77b230212cf16d3c9e62704518545d..bb1f741bd39505f458d5ead5cb6d04f798b9f489 100644 (file)
@@ -225,6 +225,26 @@ sub postfleetsupdates : Local {
        $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 ) = @_;
index 3d134e49da106a47620c2c57ab5f4ba1d87b3cef..1adec4ab3d35bf7f4c0378a55767f1ee43daeccc 100644 (file)
@@ -39,7 +39,7 @@
        <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 %]
diff --git a/root/src/members/ircrequest.tt2 b/root/src/members/ircrequest.tt2
new file mode 100644 (file)
index 0000000..5c5c8d4
--- /dev/null
@@ -0,0 +1,14 @@
+[% 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>
diff --git a/templates/defrequest.tmpl b/templates/defrequest.tmpl
deleted file mode 100644 (file)
index c2fdeb4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<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>