Unverified Commit 1ddd9cc8 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #605 from ldidry/fix-27 by ldidry

Fix #27 — Missing admin function to bulk unsubscribe
parents 4be974c3 0beb2783
......@@ -118,7 +118,28 @@
<strong>
[%|loc%]Do you really want to unsubscribe ALL selected subscribers?[%END%]
</strong>
<ul>
[% FOREACH e = email ~%]
<li>[% e %]</li>
[%~ END %]
</ul>
</p>
[%~ ELSIF confirm_action == 'mass_del' ~%]
<h2>
<i class="fa fa-check-circle"></i>
[%|loc%]Delete email address from selected lists[%END%]
</h2>
<p>
<strong>
[% SET target = "&lt;${email}&gt;" ~%]
[%|loc(target)%]Do you really want to unsubscribe %1 from the following lists?[%END%]
</strong>
</p>
<ul>
[%~ FOREACH list = lists %]
<li>[% list %]</li>
[%~ END %]
</ul>
[%~ ELSIF confirm_action == 'delete_account' ~%]
<h2>
<i class="fa fa-check-circle"></i>
......@@ -396,6 +417,16 @@
[% IF quiet %]checked="checked"[%END%] />
<label for="quiet">[%|loc%]Quiet (don't send deletion email)[%END%]</label>
</div>
[%~ ELSIF confirm_action == 'mass_del' ~%]
[% FOREACH list = lists ~%]
<input type="hidden" name="lists" value="[% list %]" />
[%~ END %]
<input type="hidden" name="email" value="[% email %]" />
<div>
<input type="checkbox" id="quiet" name="quiet" value="1"
[% IF quiet %]checked="checked"[%END%] />
<label for="quiet">[%|loc%]Quiet (don't send deletion email)[%END%]</label>
</div>
[%~ ELSIF confirm_action == 'delete_account' ~%]
<fieldset>
<input type="hidden" name="passwd" value="x"/>
......
......@@ -3,9 +3,15 @@
<h2><i class="fa fa-search"></i> [%|loc%]User search result:[%END%]</h2>
<br />
[% IF which %]
<table class="responsive listOfItems">
<table class="responsive listOfItems toggleContainer" data-toggle-selector="input[name='lists']">
<caption>[%|loc(email)%]Lists which %1 is subscribed [%END%]</caption>
<tr>
<th>
<a href="#" data-tooltip aria-haspopup="true"
title="[%|loc%]Toggle Selection[%END%]" class="toggleButton">
<i class="fa fa-check-square-o"></i>
</a>
</th>
<th>[%|loc%]list[%END%]</th>
<th>[%|loc%]role[%END%]</th>
<th>[%|loc%]reception[%END%]</th>
......@@ -21,6 +27,11 @@
[% SET dark = 1 %]
<tr class="color0">
[% END %]
<td>
[% IF l.value.is_member %]
<input type="checkbox" name="lists" value="[% l.key %]" form="mass_del"/>
[% END %]
</td>
<td>
<a href="[% 'info' | url_rel([l.key]) %]" >
<strong>[%|obfuscate(conf.spam_protection) %][% l.key %]@[% domain %][% END %]</strong>
......@@ -40,14 +51,14 @@
<td>
[% l.value.bounce %]
</td>
[% IF l.value.subscribed %]
[% IF l.value.is_member %]
<td>
<form action="[% path_cgi %]" method="post">
<fieldset>
<input type="hidden" name="previous_action" value="search_user" />
<input type="hidden" name="email" value="[% email %]" />
<input type="hidden" name="list" value="[% l.key %]" />
<input class="MainMenuLinks" type="submit" name="action_del" value="[%|loc%]delete[%END%]" />
<input class="MainMenuLinks" type="submit" name="action_del" value="[%|loc%]Unsubscribe the User[%END%]" />
<input id="quiet" type="checkbox" name="quiet" /> <label for="quiet">[%|loc%]quiet[%END%]</label>
</fieldset>
</form>
......@@ -68,6 +79,21 @@
</tr>
[% END %]
</table>
<form action="[% path_cgi %]" method="post" id="mass_del">
</form>
<div>
<input class="MainMenuLinks disableUnlessChecked"
data-selector="input[name='lists']" form="mass_del"
type="submit" name="action_mass_del"
value="[%|loc%]Delete selected email addresses[%END%]" />
</div>
<div>
<input type="checkbox" id="quiet" name="quiet" form="mass_del"/>
<label for="quiet">
[%|loc%]Quiet (don't send deletion email)[%END%]
</label>
</div>
<input type="hidden" name="email" value="[% email %]" form="mass_del"/>
[% ELSE %]
<p>[%|loc%]No mailing list available.[%END%]</p>
[% END %]
......
......@@ -194,6 +194,7 @@ our %comm = (
'auth_add' => 'do_auth_add',
'del' => 'do_del',
'auth_del' => 'do_auth_del',
'mass_del' => 'do_mass_del',
'modindex' => 'do_modindex',
'docindex' => 'do_docindex',
'reject' => 'do_reject',
......@@ -676,6 +677,7 @@ our %required_privileges = (
'edit_config' => ['listmaster'],
'ls_templates' => ['listmaster'],
'manage_template' => ['owner'],
'mass_del' => ['listmaster'],
'rt_create' => ['owner'],
'rt_delete' => ['owner'],
'rt_edit' => ['owner'],
......@@ -7313,6 +7315,79 @@ sub do_auth_del {
 
return ($in{'previous_action'} || 'sigindex');
}
# Deletes user from lists (requested by listmaster)
sub do_mass_del {
wwslog('info', '(%s) (%s)', $in{'email'},
join(', ', split /\0/, $in{'lists'}));
# Access control is done by %required_privileges
# Turn data into usable structures
my @lists = split /\0/, $in{'lists'};
my $email = Sympa::Tools::Text::canonic_email($in{'email'});
return $in{'previous_action'} || 'serveradmin'
unless Sympa::Tools::Text::valid_email($email);
# Action confirmed?
$param->{'email'} = $email;
$param->{'lists'} = \@lists;
$param->{'quiet'} = $in{'quiet'};
my $next_action = $session->confirm_action(
$in{'action'}, $in{'response_action'},
arg => join(',', @lists),
previous_action => 'serveradmin'
);
return $next_action unless $next_action eq '1';
for my $list (@lists) {
return $in{'previous_action'} || 'serveradmin' unless $email;
next unless Sympa::List->new($list, $robot, {just_try => 1});
$list = Sympa::List->new($list, $robot);
my $stash = [];
my $processed = 0;
my $spindle = Sympa::Spindle::ProcessRequest->new(
context => $list,
action => 'del',
email => $email,
sender => $param->{'user'}{'email'},
quiet => $param->{'quiet'},
md5_check => 1,
scenario_context => {
email => $email,
sender => $param->{'user'}{'email'},
remote_host => $param->{'remote_host'},
remote_addr => $param->{'remote_addr'}
},
stash => $stash,
);
$spindle and $processed += $spindle->spin;
unless ($processed) {
return $in{'previous_action'} || 'serveradmin';
}
foreach my $report (@$stash) {
if ($report->[1] eq 'notice') {
Sympa::WWW::Report::notice_report_web(@{$report}[2, 3],
$param->{'action'});
} else {
Sympa::WWW::Report::reject_report_web(@{$report}[1 .. 3],
$param->{action});
}
}
unless (@$stash) {
Sympa::WWW::Report::notice_report_web('performed', {},
$param->{'action'});
}
# Skip search because we don't have the expression anymore.
delete $in{'previous_action'} if $in{'previous_action'} eq 'search';
}
return $in{'previous_action'} || 'serveradmin';
}
 
####################################################
# do_modindex
......
......@@ -3824,7 +3824,7 @@ sub add_list_member {
my $current_list_members_count = 0;
if ($self->{'admin'}{'max_list_members'} > 0) {
$current_list_members_count = $self->get_total; # FIXME: high db load
$current_list_members_count = $self->get_total; # FIXME: high db load
}
my $sdm = Sympa::DatabaseManager->instance;
......
......@@ -2789,7 +2789,8 @@ sub cleanup {
$v->{'format'}{$k}{format} = $format;
} elsif ($v->{'format'}{$k}{'scenario'}) {
# Scenario format
$v->{'format'}{$k}{'format'} = Sympa::Regexps::scenario_config();
$v->{'format'}{$k}{'format'} =
Sympa::Regexps::scenario_config();
#XXX$v->{'format'}{$k}{'default'} = 'default'
#XXX unless ($p eq 'web_archive' and $k eq 'access')
#XXX or ($p eq 'archive' and $k eq 'web_access');
......
......@@ -156,8 +156,12 @@ sub new {
and ( $function eq 'include' and $name =~ m{\A[^/]+\z}
or $name =~ /\A$scenario_name_re\z/)
) {
$log->syslog('err', 'Unknown or undefined scenario function "%s", scenario name "%s"',
$function, $name);
$log->syslog(
'err',
'Unknown or undefined scenario function "%s", scenario name "%s"',
$function,
$name
);
return undef;
}
......@@ -1620,7 +1624,7 @@ sub get_scenarios {
my $scenario =
Sympa::Scenario->new($that, $function, name => $name);
$seen{$name} = 1;
next unless (defined $scenario);
next unless (defined $scenario);
push @scenarios, $scenario;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment