]> ruin.nu Git - ndwebbie.git/commitdiff
mailing
authorMichael Andreen <harv@ruin.nu>
Mon, 22 Jan 2007 12:23:04 +0000 (12:23 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 22 Jan 2007 12:23:04 +0000 (12:23 +0000)
ND/Web/Pages/Mail.pm [new file with mode: 0644]
startup.pl
templates/mail.tmpl [new file with mode: 0644]
templates/skel.tmpl

diff --git a/ND/Web/Pages/Mail.pm b/ND/Web/Pages/Mail.pm
new file mode 100644 (file)
index 0000000..98f5c2e
--- /dev/null
@@ -0,0 +1,77 @@
+#**************************************************************************
+#   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 ND::Web::Pages::Mail;
+use strict;
+use warnings FATAL => 'all';
+use CGI qw/:standard/;
+use Mail::Sendmail;
+
+use ND::Web::Forum;
+use ND::Web::Include;
+
+use base qw/ND::Web::XMLPage/;
+
+$ND::Web::Page::PAGES{mail} = __PACKAGE__;
+
+sub render_body {
+       my $self = shift;
+       my ($BODY) = @_;
+
+       my $DBH = $self->{DBH};
+
+       $self->{TITLE} = 'Mail members';
+
+       return $self->noAccess unless $self->isHC;
+
+       my $groups = $DBH->prepare(q{SELECT gid,groupname FROM groups ORDER BY gid});
+       $groups->execute;
+       my @groups;
+       while (my $group = $groups->fetchrow_hashref){
+               push @groups,$group;
+       }
+       $BODY->param(Groups => \@groups);
+
+       if (defined param('cmd')){
+               my $emails = $DBH->prepare(q{SELECT email FROM users WHERE (uid IN (SELECT uid FROM groupmembers WHERE gid = $1) OR $1 = -1) AND email is not null});
+               $emails->execute(param('group'));
+               my @emails;
+               while (my $email = $emails->fetchrow_hashref){
+                       push @emails,$email->{email};
+               }
+               $ND::ERROR .= p (join ', ',@emails);
+
+               my %mail = (
+                       smtp => 'ruin.nu',
+                       To      => (join ',',@emails),
+                       From    => 'NewDawn Command <nd@ruin.nu>',
+                       'Content-type' => 'text/plain; charset="UTF-8"',
+                       Subject => param('subject'),
+                       Message => param('message'),
+               );
+
+               if (sendmail %mail) {
+                       $ND::ERROR .= p "Mail sent OK.\n" 
+               }else {
+                       $ND::ERROR .= p $Mail::Sendmail::error;
+               }
+       }
+       return $BODY;
+}
+1;
index 77a315204d38bf85b0269d42298ef129e3a9964a..186b0c8ae3f2e9c62684694ed4e0e14da85790b3 100644 (file)
@@ -15,6 +15,8 @@ use GD::Graph::lines;
 
 use BBCode::Parser;
 
 
 use BBCode::Parser;
 
+use Mail::Sendmail;
+
 use ND;
 use ND::DB;
 use ND::Include;
 use ND;
 use ND::DB;
 use ND::Include;
@@ -48,6 +50,7 @@ use ND::Web::Pages::Motd;
 use ND::Web::Pages::Forum;
 use ND::Web::Pages::Settings;
 use ND::Web::Pages::Graph;
 use ND::Web::Pages::Forum;
 use ND::Web::Pages::Settings;
 use ND::Web::Pages::Graph;
+use ND::Web::Pages::Mail;
 
 
 
 
 
 
diff --git a/templates/mail.tmpl b/templates/mail.tmpl
new file mode 100644 (file)
index 0000000..7813b7a
--- /dev/null
@@ -0,0 +1,16 @@
+<TMPL_VAR NAME=Error>
+<TMPL_LOOP Scans>
+<p><TMPL_VAR NAME=Scan> <TMPL_VAR NAME=Message></p>
+</TMPL_LOOP>
+
+<form action="<TMPL_VAR NAME=PAGE>" method="post"><fieldset> <legend>Intel</legend>
+       Subject: <input type="text" name="subject" value=""/>
+       <br/>To: <select name="group">
+               <TMPL_LOOP Groups>
+               <option value="<TMPL_VAR NAME=GID>"><TMPL_VAR NAME=GroupName></option>
+               </TMPL_LOOP>
+       </select>
+       <br/><textarea rows="20" cols="50" name="message"></textarea>
+       <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>"/>
+       <br/><input type="submit" name="cmd" value="Submit"/>
+</fieldset></form>
index c4d4174b90e4f6f8b4094192fa0d9682dc434302..6ae06911697a1a8568eeb2cb7049c0bb2c8a2e3b 100644 (file)
@@ -67,6 +67,7 @@
                <li><a href="/memberIntel">Member Intel</a></li>
                <li><a href="/resources">Alliance resources</a></li>
                <li><a href="/planetNaps">Planet Naps</a></li>
                <li><a href="/memberIntel">Member Intel</a></li>
                <li><a href="/resources">Alliance resources</a></li>
                <li><a href="/planetNaps">Planet Naps</a></li>
+               <li><a href="/mail">Mail</a></li>
        </ul>
        <TMPL_ELSE>
                <TMPL_IF isIntel>
        </ul>
        <TMPL_ELSE>
                <TMPL_IF isIntel>