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",
"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. ".
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");
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");
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";
$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";
$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;
}
<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
<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: </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> </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>