3 # Store the members of some list
5 require './majordomo-lib.pl';
7 %access = &get_module_acl();
8 &can_edit_list(\%access, $in{'name'}) || &error($text{'edit_ecannot'});
9 $access{'edit'} || &error($text{'members_eedit'});
10 $list = &get_list($in{'name'}, &get_config());
11 $conf = &get_list_config($list->{'config'});
12 $pass = &find_value("admin_passwd", $conf);
13 $wrapper_path = $config{'wrapper_path'} || "$config{'program_dir'}/wrapper";
15 # find the list owner's email address
16 $aliases_files = &get_aliases_file();
17 @aliases = &foreign_call($aliases_module, "list_aliases", $aliases_files);
18 foreach $a (@aliases) {
19 if ($a->{'name'} eq "owner-$in{'name'}" ||
20 $a->{'name'} eq "$in{'name'}-owner") {
21 $owner = $a->{'values'}->[0];
25 &lock_file($list->{'members'});
27 # save the new list of members
28 $in{'members'} =~ s/\r//g;
29 $in{'members'} =~ s/\n*$/\n/;
30 &open_tempfile(MEMS, ">$list->{'members'}");
31 &print_tempfile(MEMS, $in{'members'});
32 &close_tempfile(MEMS);
33 &unlock_file($list->{'members'});
34 &webmin_log("members", undef, $in{'name'});
37 # call majordomo to subscribe an address
38 $pass || &error($text{'members_esub'});
39 $in{'addr_a'} =~ /^(\S+)\@(\S+)\.(\S+)$/ ||
40 &error($text{'members_esubaddr'});
41 open(WRAPPER, "|$wrapper_path majordomo");
42 printf WRAPPER "From: %s\n\n",
43 $owner ? $owner : $in{'addr_a'};
44 print WRAPPER "approve $pass subscribe $in{'name'} $in{'addr_a'}\n\n";
47 &unlock_file($list->{'members'});
48 &webmin_log("subscribe", undef, $in{'name'},
49 { 'addr' => $in{'addr_a'} });
51 elsif ($in{'remove'}) {
52 # call majordomo to unsubscribe an address
53 $pass || &error($text{'members_eunsub'});
54 $in{'addr_r'} =~ /^(\S+)\@(\S+)\.(\S+)$/ ||
55 &error($text{'members_eunsubaddr'});
56 open(WRAPPER, "|$wrapper_path majordomo");
57 printf WRAPPER "From: %s\n\n",
58 $owner ? $owner : $in{'addr_r'};
59 print WRAPPER "approve $pass unsubscribe $in{'name'} $in{'addr_r'}\n\n";
62 &unlock_file($list->{'members'});
63 &webmin_log("unsubscribe", undef, $in{'name'},
64 { 'addr' => $in{'addr_r'} });
66 &redirect("edit_list.cgi?name=$in{'name'}");