Skip to content

Commit

Permalink
[-dev] (r12907) Also add, add_frommod, del and del_fromsig no longer …
Browse files Browse the repository at this point in the history
…use javascript to confirm action. After all, any actions no longer use javascript to confirm action!

ToDo: Regression tests.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12921 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
  • Loading branch information
sikeda committed Aug 11, 2016
1 parent bda3315 commit 7067276
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 35 deletions.
68 changes: 62 additions & 6 deletions default/web_tt2/confirm_action.tt2
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
<!-- $Id$ -->
[% IF confirm_action == 'arc_delete' ~%]
[% IF confirm_action == 'add' ~%]
[%# Confirmation is required only by show_exclude action. ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Restore selected email addresses[%END%]"
</h2>
<p><strong>
[%|loc%]Do you really want to restore subscription for ALL selected addresses?[%END%]
</strong></p>
[%~ ELSIF confirm_action == 'add_frommod' ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Add subscribers[%END%]
</h2>
<p><strong>
[%|loc(email.0)%]Dou you really want to add %1?[%END%]
</strong></p>
[%~ ELSIF confirm_action == 'arc_delete' ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Delete Selected Month(s)[%END%]
</h2>
<p><strong>
[%|loc%]Do you really want to delete Selected Archives?[%END%]
</strong></p>
[% ELSIF confirm_action == 'close_list' ~%]
[%~ ELSIF confirm_action == 'close_list' ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Remove List[%END%]
</h2>
<p><strong>
[%|loc(list)%]Are you sure you wish to close list %1?[%END%]
</strong></p>
[% ELSIF confirm_action == 'd_admin' && d_admin == 'delete' ~%]
[%~ ELSIF confirm_action == 'del' ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Delete selected email addresses[%END%]
</h2>
<p><strong>
[%|loc%]Do you really want to unsubscribe ALL selected subscribers?[%END%]
</strong></p>
[%~ ELSIF confirm_action == 'del_fromsig' ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Delete selected addresses[%END%]
</h2>
<p><strong>
[%|loc%]Do you really want to unsubscribe ALL selected subscribers?[%END%]
</strong></p>
[%~ ELSIF confirm_action == 'd_admin' && d_admin == 'delete' ~%]
<h2><i class="fa fa-check-circle"></i>
[%|loc%]Delete Shared[%END%]
</h2>
Expand Down Expand Up @@ -79,15 +108,42 @@
[%~ END %]

<form action="[% path_cgi %]" method="POST">
[% IF confirm_action == 'arc_delete' ~%]
[% IF confirm_action == 'add' ~%]
<input type="hidden" name="previous_action" value="show_exclude" />
[% FOREACH e = email ~%]
<input type="hidden" name="email" value="[% e %]" />
[%~ END %]
<div>
<input type="checkbox" id="quiet" type="checkbox" name="quiet" value="1"
[% IF quiet %]checked="checked"[%END%] />
<label for="quiet">[%|loc%]Quiet (don't send welcome email)[%END%]</label>
</div>
[%~ ELSIF confirm_action == 'add_frommod' ~%]
[% FOREACH i = id ~%]
<input type="hidden" name="id" value="[% i %]" />
[%~ END %]
[%~ ELSIF confirm_action == 'arc_delete' ~%]
[% FOREACH d = directories ~%]
<input type="hidden" name="directories" value="[% d %]" />
[%~ END %]
<div>
<input type="checkbox" id="zip" name="zip" value="1" checked="checked" />
<label for="zip">[%|loc%]Download deleted archives[%END%]</label>
</div>
[% ELSIF confirm_action == 'd_admin' && d_admin == 'delete' ~%]
[%~ ELSIF confirm_action == 'del' ~%]
[% FOREACH e = email ~%]
<input type="hidden" name="email" value="[% e %]" />
[%~ END %]
<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 == 'del_fromsig' ~%]
[% FOREACH i = id ~%]
<input type="hidden" name="id" value="[% i %]" />
[%~ END %]
[%~ ELSIF confirm_action == 'd_admin' && d_admin == 'delete' ~%]
<input type="hidden" name="d_admin" value="[% d_admin %]" />
[%~ ELSIF confirm_action == 'd_delete' ~%]
<input type="hidden" name="path" value="[% shared_doc.paths.join("/") %]" />
Expand All @@ -110,7 +166,7 @@
<input type="hidden" name="action" value="[% confirm_action %]" />
<input type="hidden" name="list" value="[% list %]" />
<div>
<input class="MainMenuLinks heavyWork" type="submit"
<input class="MainMenuLinks" type="submit"
id="response_action_confirm" name="response_action_confirm"
value="[%|loc%]Confirm[%END%]" />
<input class="MainMenuLinks" type="submit"
Expand Down
19 changes: 14 additions & 5 deletions default/web_tt2/exclusion_table.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@
[% END %]
[% END %]
</table>
[% IF may_add %]
<input class="MainMenuLinks" type="button" value="[%|loc%]Toggle Selection[%END%]" onclick="toggle_selection(document.show_exclude.email)" /><br />
<input class="MainMenuLinks" type="submit" name="action_add" value="[%|loc%]Restore selected email addresses[%END%]" onclick="return request_confirm('[%|loc%]Do you really want to restore subscription for ALL selected addresses?[%END%]')" />
<input id="quiet_exclusion" type="checkbox" name="quiet"/> <label for="quiet_exclusion">[%|loc%]quiet[%END%] </label>
[% END %]
[% IF may_add %]
<div>
<input class="MainMenuLinks" type="button"
value="[%|loc%]Toggle Selection[%END%]"
onclick="toggle_selection(document.show_exclude.email)" /><br />
</div>
<div>
<input class="MainMenuLinks" type="submit" name="action_add"
value="[%|loc%]Restore selected email addresses[%END%]" />
<input id="quiet_exclusion" type="checkbox" name="quiet"/>
<label for="quiet_exclusion">[%|loc%]quiet[%END%] </label>
<input type="hidden" name="previous_action" value="[% action %]" />
</div>
[% END %]

</fieldset>
</form>
Expand Down
4 changes: 2 additions & 2 deletions default/web_tt2/modform.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<input type="hidden" name="id" value="[% msg.key %]" />
<input type="hidden" name="from_modindex" value="from_modindex" />
<button class="action" type="submit" name="action_add_frommod"
onclick="return request_confirm('[%|loc(msg.value.from)%]Dou you really want to add %1?[%END%]');"
value="[%|loc%]Add subscribers[%END%]" data-tooltip aria-haspopup="true" title="[%|loc%]Add subscribers[%END%]"><i class="fa fa-user-plus fa-lg"></i>[% IF mod_display_message %] [%|loc%]Add subscribers[%END%][% END %]</button>
value="[%|loc%]Add subscribers[%END%]" data-tooltip aria-haspopup="true"
title="[%|loc%]Add subscribers[%END%]"><i class="fa fa-user-plus fa-lg"></i>[% IF mod_display_message %] [%|loc%]Add subscribers[%END%][% END %]</button>
</form>
[% END %]
[% END %]
Expand Down
23 changes: 17 additions & 6 deletions default/web_tt2/review.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,23 @@
[% END %]

[% IF total != 0 %]
[% IF is_owner %]
<input class="MainMenuLinks" type="button" value="[%|loc%]Toggle Selection[%END%]" onclick="toggle_selection(document.myform.email)" />
<br /><input class="MainMenuLinks" type="submit" name="action_del" value="[%|loc%]Delete selected email addresses[%END%]" onclick="return request_confirm('[%|loc%]Do you really want to unsubscribe ALL selected subscribers?[%END%]')" />
<br /><input type="checkbox" name="quiet" /> [%|loc%]Quiet (don't send deletion email)[%END%]
[% END %]
<hr>
[% IF is_owner %]
<div>
<input class="MainMenuLinks" type="button"
value="[%|loc%]Toggle Selection[%END%]"
onclick="toggle_selection(document.myform.email)" />
</div>
<div>
<input class="MainMenuLinks" type="submit" name="action_del"
value="[%|loc%]Delete selected email addresses[%END%]" />
<br />
<input type="checkbox" id="quiet" name="quiet" />
<label for="quiet">
[%|loc%]Quiet (don't send deletion email)[%END%]
</label>
</div>
[% END %]
<hr>

[% IF action == 'search' %]
<h4>[%|loc%]Excluded users[%END%]</h4>
Expand Down
16 changes: 11 additions & 5 deletions default/web_tt2/reviewbouncing.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,17 @@
[% END %]
</div>
[% IF is_owner %]
<br />
<input class="MainMenuLinks" type="submit" name="action_del" value="[%|loc%]Delete selected email addresses[%END%]" />
<input id="quiet" type="checkbox" name="quiet" /> <label for="quiet">[%|loc%]quiet[%END%] </label><br />
<input class="MainMenuLinks" type="submit" name="action_resetbounce" value="[%|loc%]Reset errors for selected users[%END%]" /><br />
[% END %]
<div>
<input class="MainMenuLinks" type="submit" name="action_del"
value="[%|loc%]Delete selected email addresses[%END%]" />
<input id="quiet" type="checkbox" name="quiet" />
<label for="quiet">[%|loc%]quiet[%END%] </label>
</div>
<div>
<input class="MainMenuLinks" type="submit" name="action_resetbounce"
value="[%|loc%]Reset errors for selected users[%END%]" />
</div>
[% END %]

<input class="MainMenuLinks" type="button" value="[%|loc%]Toggle Selection[%END%]" onclick="toggle_selection(document.myform.email)" />
</fieldset>
Expand Down
14 changes: 11 additions & 3 deletions default/web_tt2/sigindex.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@
</table>
<input type="hidden" name="previous_action" value="sigindex" />
<input type="hidden" name="previous_list" value="[% list %]" />
<input class="MainMenuLinks" type="button" value="[%|loc%]Toggle Selection[%END%]" onclick="toggle_selection(document.myform.id)" />
<input class="MainMenuLinks" type="submit" name="action_del_fromsig" value="[%|loc%]Delete selected addresses[%END%]" />
<input class="MainMenuLinks" type="submit" name="action_ignoresig" value="[%|loc%]Reject selected addresses[%END%]" />
<div>
<input class="MainMenuLinks" type="button"
value="[%|loc%]Toggle Selection[%END%]"
onclick="toggle_selection(document.myform.id)" />
</div>
<div>
<input class="MainMenuLinks" type="submit" name="action_del_fromsig"
value="[%|loc%]Delete selected addresses[%END%]" />
<input class="MainMenuLinks" type="submit" name="action_ignoresig"
value="[%|loc%]Reject selected addresses[%END%]" />
</div>
</fieldset>
</form>
[% ELSE %]
Expand Down
64 changes: 56 additions & 8 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -7670,6 +7670,21 @@ sub do_add {
return undef;
}

my @emails = split /\0/, $in{'email'};

if ($in{'previous_action'} and $in{'previous_action'} eq 'show_exclude') {
$param->{'email'} = [@emails];
$param->{'quiet'} = $in{'quiet'};

# Action confirmed?
my $next_action = $session->confirm_action(
$in{'action'}, $in{'response_action'},
arg => join(',', sort @emails),
previous_action => $in{'previous_action'}
);
return $next_action unless $next_action eq '1';
}

my $email_regexp = Sympa::Regexps::email();
if ($in{'dump'}) {
foreach (split /\n/, $in{'dump'}) {
Expand Down Expand Up @@ -8003,7 +8018,19 @@ sub do_add_fromsub {
sub do_del {
wwslog('info', '');

$in{'email'} = Sympa::Tools::Text::unescape_chars($in{'email'});
$in{'email'} = Sympa::Tools::Text::unescape_chars($in{'email'}); #FIXME
my @emails = split /\0/, $in{'email'};

$param->{'email'} = [@emails];
$param->{'quiet'} = $in{'quiet'};

# Action confirmed?
my $next_action = $session->confirm_action(
$in{'action'}, $in{'response_action'},
arg => join(',', sort @emails),
previous_action => ($in{'previous_action'} || 'review')
);
return $next_action unless $next_action eq '1';

my $result = Sympa::Scenario::request_action(
$list, 'del',
Expand Down Expand Up @@ -8035,8 +8062,6 @@ sub do_del {
return undef;
}

my @emails = split /\0/, $in{'email'};

my ($total, @removed_users);

foreach my $email (@emails) {
Expand Down Expand Up @@ -8156,8 +8181,19 @@ sub do_del_fromsig {
return undef;
}

my @ids = split /\0/, $in{'id'};
$param->{'id'} = [@ids];

# Action confirmed?
my $next_action = $session->confirm_action(
$in{'action'}, $in{'response_action'},
arg => join(',', sort @ids),
previous_action => 'sigindex'
);
return $next_action unless $next_action eq '1';

my $total = 0;
foreach my $id (split /\0/, $in{'id'}) {
foreach my $id (@ids) {
next unless $id and $id =~ /\A\w+\z/;

my $spool_req = Sympa::Spool::Auth->new(
Expand Down Expand Up @@ -8819,14 +8855,15 @@ sub do_distribute {
#
####################################################
sub do_add_frommod {
$in{'id'} =~ s/^,//;
$in{'id'} =~ s/\0/,/g;

wwslog('info', '(%s)', $in{'id'});

my @ids = split /\0/, $in{'id'};
$param->{'id'} = [@ids];

my @emails;
# Load message list.
$in{'dump'} = '';
foreach my $id (split /,/, $in{'id'}) {
foreach my $id (@ids) {
next unless $id and $id =~ /\A\w+\z/;

my $spool_mod =
Expand Down Expand Up @@ -8860,7 +8897,18 @@ sub do_add_frommod {
} else {
$in{'dump'} .= "$email\n";
}

push @emails, $email;
}
$param->{'email'} = [@emails];

# Action confirmed?
my $next_action = $session->confirm_action(
$in{'action'}, $in{'response_action'},
arg => join(',', sort @ids),
previous_action => 'modindex'
);
return $next_action unless $next_action eq '1';

if ($in{'dump'}) {
delete $in{'email'};
Expand Down
1 change: 1 addition & 0 deletions www/js/sympa.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function hideError() {
}

// To confirm a form submition
// NO LONGER USED as of 6.2.17.
function request_confirm(my_message) {
return !!confirm(my_message);
}
Expand Down

0 comments on commit 7067276

Please sign in to comment.