]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
perl interface update from xi
authormmj <none@none>
Fri, 26 Nov 2004 14:36:27 +0000 (01:36 +1100)
committermmj <none@none>
Fri, 26 Nov 2004 14:36:27 +0000 (01:36 +1100)
contrib/web/perl-admin/conf/tunables.pl
contrib/web/perl-admin/htdocs/subscribers.cgi
contrib/web/perl-admin/templates/edit.html
contrib/web/perl-admin/templates/save.html
contrib/web/perl-admin/templates/subscribers.html
contrib/web/perl-admin/templates/subscribers_row.html

index 2cd4b03dcf4b5c821581a842ba75bfbb8a889c4e..ca8a3cf126acf446173be3aea08903a3ccae1461 100644 (file)
@@ -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");
index 6cf4697446f1aa2a298cb923e64f1e7821e822ff..ef3b3aaacbce7c32cf2cd9d8d2883ce28b4acfaa 100755 (executable)
@@ -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.<br>\n";
-                               } else {
-                                       $action .= "$email was not unsubscribed.<br>\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.<br>\n";
                                }
                        } else {
                                $action .= '"'.encode_entities($email).'" is not a valid email address.'."<br>\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 (<FILE>) {
-                               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 (<FILE>) {
-                               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;
 }
index 8485faa360296fce43aa9047b7ffdd77d3e989bc..e442aa9d2df2412dd9dc44d8046c2885f44974fa 100644 (file)
@@ -1,10 +1,13 @@
 <html><head><title>mlmmj config</title></head><body>
 <h1>mlmmj config</h1>
+<p>
+<a href="index.cgi">Index</a> | <a href="subscribers.cgi?list=$LIST">Subscribers</a>
+</p>
 <form method="post" action="save.cgi">
 <input type="hidden" name="list" value="$LIST">
 <table border="1">
 $ROWS
 </table>
-<input type="submit" name="submit" />
+<input type="submit" name="submit" value="Update configuration" />
 </form>
 </body></html>
index 1ee8ee84d86c00b3584bcbf80ed4fcc84c210e8b..147dea408d64c26aa04e85ee8d38368827800a84 100644 (file)
@@ -4,6 +4,6 @@
 $LIST control values saved!
 </p>
 <p>
-<a href="index.cgi">Index</a> | <a href="edit.cgi?list=$LIST">$LIST</a>
+<a href="index.cgi">Index</a> | <a href="edit.cgi?list=$LIST">Back to configuration</a>
 </p>
 </body></html>
index 8c3c1b755a3459e20c6429269ff9a9e0674e1979..1768ac3067032f3d60625e4d8278286dde88a214 100644 (file)
@@ -1,7 +1,7 @@
 <html><head><title>mlmmj subscribers</title></head><body>
 <h1>mlmmj subscribers</h1>
 <p>
-<a href="index.cgi">Index</a> | <a href="subscribers.cgi?list=$LIST">Reload subscriber list</a>
+<a href="index.cgi">Index</a> | <a href="subscribers.cgi?list=$LIST">Reload subscriber list</a> | <a href="edit.cgi?list=$LIST">Configure</a>
 </p>
 <p>
 $ACTION
@@ -9,11 +9,18 @@ $ACTION
 <form action="subscribers.cgi" method="post">
 <input type="hidden" name="list" value="$LIST">
 <input type="hidden" name="maxid" value="$MAXID">
-<p>Add subscriber: <input type="text" name="email"> <input type="submit" name="subscribe" value="Subscribe"></p>
+<table><tr><td rowspan="4" valign="top">Add subscriber:&nbsp;&nbsp;</td>
+<td>Email address: <input type="text" name="email"></td></tr>
+<tr><td>Normal subscriber: <input type="checkbox" name="subscriber" value="1" checked></td></tr>
+<tr><td>Digest subscriber: <input type="checkbox" name="digester" value="1"></td></tr>
+<tr><td>No-mail subscriber: <input type="checkbox" name="nomailsub" value="1"></td></tr>
+<tr><td>&nbsp;</td><td><input type="submit" name="subscribe" value="Subscribe"></td></tr>
+</table>
+<hr>
 <table border="1">
-<tr><th>Email address</th><th>Unsubscribe</th></tr>
+<tr><th>Email address</th><th>Normal subscriber</th><th>Digest subscriber</th><th>No-mail subscriber</th></tr>
 $ROWS
 </table>
-<p><input type="submit" name="unsubscribe" value="Unsubscribe selected"></p>
+<p><input type="submit" name="update" value="Update subscriptions"></p>
 </form>
 </body></html>
index 198bf03838a436a2df22a646ac9be44c70ccf385..8582c6455c742b4692d6f2a7c6354f414d916f53 100644 (file)
@@ -1 +1,6 @@
-<tr><td>$EMAIL</td><td><input type="checkbox" name="email$ID" value="$EMAIL"></td></tr>
+<tr>
+    <td>$EMAIL<input type="hidden" name="email$ID" value="$EMAIL"></td>
+    <td><input type="checkbox" name="subscriber$ID" value="1" $SCHECKED></td>
+    <td><input type="checkbox" name="digester$ID" value="1" $DCHECKED></td>
+    <td><input type="checkbox" name="nomailsub$ID" value="1" $NCHECKED></td>
+</tr>