From: mmj Date: Fri, 26 Nov 2004 14:36:27 +0000 (+1100) Subject: perl interface update from xi X-Git-Tag: RELEASE_1_1_0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50c5426962859eea24b3540aa85cf34a403ed253;p=thirdparty%2Fmlmmj.git perl interface update from xi --- diff --git a/contrib/web/perl-admin/conf/tunables.pl b/contrib/web/perl-admin/conf/tunables.pl index 2cd4b03d..ca8a3cf1 100644 --- a/contrib/web/perl-admin/conf/tunables.pl +++ b/contrib/web/perl-admin/conf/tunables.pl @@ -1,6 +1,9 @@ mlmmj_boolean("closedlist", "Closed list", - "If this option is set, subscribtion and unsubscription via mail is disabled."); + "If the list is open or closed. If it's closed subscription ". + "and unsubscription via mail is disabled. Also note that ". + "confirmation is disabled too, so the -C option to mlmmj-sub ". + "and mlmmj-unsub is of no use with a closed list."); mlmmj_boolean("nosubconfirm", "No subscribe confirmation", @@ -37,6 +40,13 @@ mlmmj_list("owner", "Owner", "The emailaddresses in this list will get mails to ".encode_entities($list)."+owner"); +mlmmj_list("customheaders", + "Custom headers", + "These headers are added to every mail coming through. This is ". + "the place you want to add Reply-To: header in case you want ". + "such. ". + "If a header should not occur twice in the mail it should be listed in the 'Delete headers' box too."); + mlmmj_list("delheaders", "Delete headers", "In this file is specified *ONE* headertoken to match pr. line. ". @@ -57,13 +67,32 @@ mlmmj_string("memorymailsize", mlmmj_string("relayhost", "Relay host", - "The host specified (IP address og domainname, both works) in this file will be used for relaying the mail sent to the list. ". + "The host specified (IP address or domainname, both works) in this file will be used for relaying the mail sent to the list. ". "Defaults to 127.0.0.1."); mlmmj_boolean("notifysub", "Notify subscribers", "If this option is set, the owner(s) will get a mail with the address of someone sub/unsubscribing to a mailinglist."); + +mlmmj_string("digestinterval", + "Digest interval", + "This option specifies how many seconds will pass before the ". + "next digest is sent. Defaults to 604800 seconds, which is 7 ". + "days."); + +mlmmj_string("digestmaxmails", + "Max. digest mails", + "This option specifies how many mails can accumulate before ". + "digest sending is triggered. Defaults to 50 mails, meaning ". + "that if 50 mails arrive to the list before digestinterval have ". + "passed, the digest is delivered."); + mlmmj_string("bouncelife", - "Bouncing lifetime", - "Here is specified for how long time in seconds an address can bounce before it's unsubscribed. Defaults ". - "to 432000 seconds, which is 5 days."); + "Bouncing lifetime", + "Here is specified for how long time in seconds an address can bounce before it's unsubscribed. Defaults ". + "to 432000 seconds, which is 5 days."); + +mlmmj_boolean("noarchive", + "No archive", + "If this option is set, the mails won't be saved in the ". + "archive but simply deleted"); diff --git a/contrib/web/perl-admin/htdocs/subscribers.cgi b/contrib/web/perl-admin/htdocs/subscribers.cgi index 6cf46974..ef3b3aaa 100755 --- a/contrib/web/perl-admin/htdocs/subscribers.cgi +++ b/contrib/web/perl-admin/htdocs/subscribers.cgi @@ -45,7 +45,7 @@ my $tpl = new CGI::FastTemplate($templatedir); my $q = new CGI; $list = $q->param("list"); my $subscribe = $q->param("subscribe"); -my $unsubscribe = $q->param("unsubscribe"); +my $update = $q->param("update"); die "no list specified" unless $list; die "non-existent list" unless -d("$topdir/$list"); @@ -59,27 +59,56 @@ my $subscribers; if (defined $subscribe) { my $email = $q->param("email"); + my $subscriber = $q->param("subscriber"); + my $digester = $q->param("digester"); + my $nomailsub = $q->param("nomailsub"); if ($email =~ /^[a-z0-9\.\-_\@]+$/i) { - system "$mlmmjsub -L $topdir/$list -a $email -U"; - if (is_subscribed($email)) { - $action = "$email has been subscribed."; - } else { - $action = "$email was not subscribed."; + if ($subscriber) { + system "$mlmmjsub -L $topdir/$list -a $email -U"; } + if ($digester) { + system "$mlmmjsub -L $topdir/$list -a $email -Ud"; + } + if ($nomailsub) { + system "$mlmmjsub -L $topdir/$list -a $email -Un"; + } + $action = "$email has been subscribed."; } else { $action = '"'.encode_entities($email).'" is not a valid email address.'; } -} elsif (defined $unsubscribe) { +} elsif (defined $update) { my $maxid = $q->param("maxid"); + $subscribers = get_subscribers(); for (my $i = 0; $i < $maxid; ++$i) { my $email = $q->param("email$i"); if (defined $email) { if ($email =~ /^[a-z0-9\.\-_\@]+$/i) { - system "$mlmmjunsub -L $topdir/$list -a $email"; - if (!is_subscribed($email)) { - $action .= "$email has been unsubscribed.
\n"; - } else { - $action .= "$email was not unsubscribed.
\n"; + my $updated = 0; + + my @actions = (); + + push @actions, {oldstatus => exists $subscribers->{$email}->{subscriber}, + newstatus => defined $q->param("subscriber$i"), + action => ''}; + push @actions, {oldstatus => exists $subscribers->{$email}->{digester}, + newstatus => defined $q->param("digester$i"), + action => '-d'}; + push @actions, {oldstatus => exists $subscribers->{$email}->{nomailsub}, + newstatus => defined $q->param("nomailsub$i"), + action => '-n'}; + + for my $action (@actions) { + if ($action->{oldstatus} && !$action->{newstatus}) { + system "$mlmmjunsub -L $topdir/$list -a $email $action->{action}"; + $updated = 1; + } elsif (!$action->{oldstatus} && $action->{newstatus}) { + system "$mlmmjsub -L $topdir/$list -a $email $action->{action}"; + $updated = 1; + } + } + + if ($updated) { + $action .= "Subscription for $email has been updated.
\n"; } } else { $action .= '"'.encode_entities($email).'" is not a valid email address.'."
\n"; @@ -92,17 +121,21 @@ $tpl->assign(ACTION => $action); $subscribers = get_subscribers(); -for (my $i = 0; $i < @$subscribers; ++$i) { - $tpl->assign(EMAIL => $subscribers->[$i], - ID => $i); +my $i = 0; +for my $address (sort keys %$subscribers) { + $tpl->assign(EMAIL => $address, + ID => $i++, + SCHECKED => $subscribers->{$address}->{subscriber} ? 'checked' : '', + DCHECKED => $subscribers->{$address}->{digester} ? 'checked' : '', + NCHECKED => $subscribers->{$address}->{nomailsub} ? 'checked' : ''); $tpl->parse(ROWS => '.row'); } -if (@$subscribers == 0) { +if (keys %$subscribers == 0) { $tpl->assign(ROWS => ''); } $tpl->assign(LIST => encode_entities($list), - MAXID => scalar(@$subscribers)); + MAXID => scalar(keys %$subscribers)); print "Content-type: text/html\n\n"; @@ -110,48 +143,27 @@ $tpl->parse(CONTENT => "main"); $tpl->print; sub get_subscribers { - my @subscribers = (); - - opendir (DIR, "$topdir/$list/subscribers.d") or die "Couldn't read dir $topdir/$list/subscribers.d: $!"; - my @files = grep(/^.$/, readdir(DIR)); - closedir DIR; - for my $file (@files) { - my $filename = "$topdir/$list/subscribers.d/$file"; - if (-f $filename) { - open (FILE, $filename) or die "Couldn't open $filename for reading: $!"; - while () { - chomp; - push @subscribers, $_; - } - close FILE; - } - } + my %subscribers = (); - @subscribers = sort @subscribers; + my @subscribers = `/usr/local/bin/mlmmj-list -L $topdir/$list`; + my @digesters = `/usr/local/bin/mlmmj-list -L $topdir/$list -d`; + my @nomailsubs = `/usr/local/bin/mlmmj-list -L $topdir/$list -n`; - return \@subscribers; -} + chomp @subscribers; + chomp @digesters; + chomp @nomailsubs; -sub is_subscribed { - my ($email) = @_; - - opendir (DIR, "$topdir/$list/subscribers.d") or die "Couldn't read dir $topdir/$list/subscribers.d: $!"; - my @files = grep(/^.$/, readdir(DIR)); - closedir DIR; - - for my $file (@files) { - my $filename = "$topdir/$list/subscribers.d/$file"; - if (-f $filename) { - open (FILE, $filename) or die "Couldn't open $filename for reading: $!"; - while () { - chomp; - if ($email eq $_) { - return 1; - } - } - close FILE; - } + for my $address (@subscribers) { + $subscribers{$address}->{subscriber} = 1; + } + + for my $address (@digesters) { + $subscribers{$address}->{digester} = 1; + } + + for my $address (@nomailsubs) { + $subscribers{$address}->{nomailsub} = 1; } - return 0; + return \%subscribers; } diff --git a/contrib/web/perl-admin/templates/edit.html b/contrib/web/perl-admin/templates/edit.html index 8485faa3..e442aa9d 100644 --- a/contrib/web/perl-admin/templates/edit.html +++ b/contrib/web/perl-admin/templates/edit.html @@ -1,10 +1,13 @@ mlmmj config

mlmmj config

+

+Index | Subscribers +

$ROWS
- +
diff --git a/contrib/web/perl-admin/templates/save.html b/contrib/web/perl-admin/templates/save.html index 1ee8ee84..147dea40 100644 --- a/contrib/web/perl-admin/templates/save.html +++ b/contrib/web/perl-admin/templates/save.html @@ -4,6 +4,6 @@ $LIST control values saved!

-Index | $LIST +Index | Back to configuration

diff --git a/contrib/web/perl-admin/templates/subscribers.html b/contrib/web/perl-admin/templates/subscribers.html index 8c3c1b75..1768ac30 100644 --- a/contrib/web/perl-admin/templates/subscribers.html +++ b/contrib/web/perl-admin/templates/subscribers.html @@ -1,7 +1,7 @@ mlmmj subscribers

mlmmj subscribers

-Index | Reload subscriber list +Index | Reload subscriber list | Configure

$ACTION @@ -9,11 +9,18 @@ $ACTION

-

Add subscriber:

+ + + + + + +
Add subscriber:  Email address:
Normal subscriber:
Digest subscriber:
No-mail subscriber:
 
+
- + $ROWS
Email addressUnsubscribe
Email addressNormal subscriberDigest subscriberNo-mail subscriber
-

+

diff --git a/contrib/web/perl-admin/templates/subscribers_row.html b/contrib/web/perl-admin/templates/subscribers_row.html index 198bf038..8582c645 100644 --- a/contrib/web/perl-admin/templates/subscribers_row.html +++ b/contrib/web/perl-admin/templates/subscribers_row.html @@ -1 +1,6 @@ -$EMAIL + + $EMAIL + + + +