Unverified Commit 02cc1e48 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #1379 from ikedas/issue-1329 by ikedas

WWSympa: Adding owner/moderator with non-default options does not work (#1329)
parents cf1bde60 73cc9951
......@@ -386,9 +386,14 @@
END;
END ~%]
[% IF is_writable && is_privileged_owner ~%]
[% IF pS.name == 'owner' ~%]
[% SET defopt = listconf.default_owner_options %]
[%~ ELSIF pS.name == 'editor' ~%]
[% SET defopt = listconf.default_editor_options %]
[%~ END ~%]
<h3>
[% IF pS.name == 'owner' ~%]
[%|loc%]Add owners[%END%]
[%|loc%]Add owners[%END%]
[%~ ELSIF pS.name == 'editor' ~%]
[%|loc%]Add moderators[%END%]
[%~ END %]
......@@ -397,14 +402,23 @@
<div class="row" id="item.[% pS.name %].[% oI %]" role="row">
<div class="small-10 medium-11 columns">
[% IF pS.name == 'owner' ~%]
<div class="columns show-for-medium" role="cell">
<input type="checkbox"
name="single_param.[% pS.name %].[% oI %].profile"
id="param.[% pS.name %].[% oI %].profile"
value="privileged" />
<div class="medium-3 columns show-for-medium" role="cell">
<label for="param.[% pS.name %].[% oI %].profile">
[% 'privileged' | optdesc %]
[% 'profile' | loc %]
</label>
<select name="single_param.[% pS.name %].[% oI %].profile"
id="param.[% pS.name %].[% oI %].profile">
<option value="privileged"
[%~ IF defopt.profile == 'privileged' %] selected[% END %]>
[% 'privileged' | optdesc %]
</option>
<option value="normal"
[%~ IF defopt.profile == 'normal' %] selected[% END %]>
[% 'normal' | optdesc %]
</option>
</select>
</div>
<div class="columns show-for-medium" role="cell">
</div>
[%~ END %]
......@@ -416,21 +430,35 @@
[% UNLESS kS.privilege == 'write' ~%]
&nbsp;
[%~ ELSIF kS.name == 'reception' ~%]
<input type="checkbox"
name="single_param.[% pS.name %].[% oI %].reception"
id="param.[% pS.name %].[% oI %].reception"
value="nomail" />
<label for="param.[% pS.name %].[% oI %].reception">
[% 'nomail' | optdesc %]
[% 'reception mode' | loc %]
</label>
<select name="single_param.[% pS.name %].[% oI %].reception"
id="param.[% pS.name %].[% oI %].reception">
<option value="mail"
[%~ IF defopt.reception == 'mail' %] selected[% END %]>
[% 'mail' | optdesc %]
</option>
<option value="nomail"
[%~ IF defopt.reception == 'nomail' %] selected[% END %]>
[% 'nomail' | optdesc %]
</option>
</select>
[%~ ELSIF kS.name == 'visibility' ~%]
<input type="checkbox"
name="single_param.[% pS.name %].[% oI %].visibility"
id="param.[% pS.name %].[% oI %].visibility"
value="conceal" />
<label for="param.[% pS.name %].[% oI %].visibility">
[% 'conceal' | optdesc %]
[% 'visibility' | loc %]
</label>
<select name="single_param.[% pS.name %].[% oI %].visibility"
id="param.[% pS.name %].[% oI %].visibility">
<option value="conceal"
[%~ IF defopt.visibility == 'conceal' %] selected[% END %]>
[% 'conceal' | optdesc %]
</option>
<option value="noconceal"
[%~ IF defopt.visibility == 'noconceal' %] selected[% END %]>
[% 'noconceal' | optdesc %]
</option>
</select>
[%~ ELSE ~%]
<label for="param.[% pS.name %].[% oI %].[% kS.name %]">
[% IF kS.title ~%]
......
......@@ -4620,6 +4620,10 @@ sub _review_user {
role => $role,
email => [map { $_->{email} } @add],
gecos => [map { $_->{gecos} } @add],
profile => [map { $_->{profile} } @add],
reception => [map { $_->{reception} } @add],
visibility => [map { $_->{visibility} } @add],
info => [map { $_->{info} } @add],
sender => $param->{'user'}{'email'},
quiet => $param->{'quiet'},
scenario_context => {skip => 1},
......
......@@ -996,7 +996,6 @@ our %pinfo = (
gettext_id => "reception mode",
gettext_comment => 'Mail reception mode.',
format => ['mail', 'nomail'],
field_type => 'reception',
occurrence => '1',
default => 'mail'
},
......@@ -1006,7 +1005,6 @@ our %pinfo = (
gettext_id => "visibility",
gettext_comment => 'Visibility of the owner.',
format => ['conceal', 'noconceal'],
field_type => 'visibility',
occurrence => '1',
default => 'noconceal'
},
......@@ -1026,7 +1024,6 @@ our %pinfo = (
gettext_id => "reception mode",
gettext_comment => 'Mail reception mode.',
format => ['mail', 'nomail'],
field_type => 'reception',
occurrence => '1',
default => 'mail'
},
......@@ -1036,7 +1033,6 @@ our %pinfo = (
gettext_id => "visibility",
gettext_comment => 'Visibility of the moderator.',
format => ['conceal', 'noconceal'],
field_type => 'visibility',
occurrence => '1',
default => 'noconceal'
},
......
......@@ -3170,7 +3170,15 @@ sub add_list_member {
my $values = $self->get_default_user_options(role => 'member');
while (my ($k, $v) = each %$u) {
$values->{$k} = $v if defined $v;
next unless defined $v;
# Check validity of restricted options.
# FIXME: Use @Sympa::Config::Schema::user_info.
if ($k eq 'reception') {
next unless grep { $v eq $_ } qw(mail nomail);
} elsif ($k eq 'visibility') {
next unless grep { $v eq $_ } qw(conceal noconceal);
}
$values->{$k} = $v;
}
$values->{email} = $who;
......@@ -3373,7 +3381,17 @@ sub _add_list_admin {
my $values = $self->get_default_user_options(role => $role);
while (my ($k, $v) = each %$u) {
$values->{$k} = $v if defined $v;
next unless defined $v;
# Check validity of restricted options.
# FIXME: Use @Sympa::Config::Schema::user_info.
if ($k eq 'profile') {
next unless grep { $v eq $_ } qw(privileged normal);
} elsif ($k eq 'reception') {
next unless grep { $v eq $_ } qw(mail nomail);
} elsif ($k eq 'visibility') {
next unless grep { $v eq $_ } qw(conceal noconceal);
}
$values->{$k} = $v;
}
$values->{email} = $who;
......
......@@ -51,12 +51,10 @@ sub _twist {
my $self = shift;
my $request = shift;
my $list = $request->{context};
my $sender = $request->{sender};
my $email = $request->{email};
my $comment = $request->{gecos};
my $role = $request->{role} || 'member';
my $ca = $request->{custom_attribute};
my $list = $request->{context};
my $sender = $request->{sender};
my $email = $request->{email};
my $role = $request->{role} || 'member';
die 'bug in logic. Ask developer'
unless grep { $role eq $_ } qw(member owner editor);
......@@ -74,12 +72,21 @@ sub _twist {
}
$list->add_list_member(
{email => $email, gecos => $comment, custom_attribute => $ca},
stash => \@stash);
{ email => $email,
map { ($_ => $request->{$_}) }
grep { defined $request->{$_} }
qw(gecos reception visibility custom_attribute)
},
stash => \@stash
);
} else {
$list->add_list_admin(
$role,
{email => $email, gecos => $comment},
{ email => $email,
map { ($_ => $request->{$_}) }
grep { defined $request->{$_} }
qw(gecos profile reception visibility info)
},
stash => \@stash
);
}
......
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