Skip to content

Commit

Permalink
Now the list parameter member_include may have reception & visibility…
Browse files Browse the repository at this point in the history
… as owner_include & editor_include do (#989).

Parameters to specify defaults (profile, reception & visibility) in *_include parameters may be optional and values in corresponding default_*_options parameters will be used as the defaults.
  • Loading branch information
ikedas committed Nov 7, 2021
1 parent 061f5a8 commit 0328681
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
46 changes: 36 additions & 10 deletions src/lib/Sympa/Config/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2818,6 +2818,31 @@ our %pinfo = (
format => '.*',
occurrence => '0-1'
},
reception => {
context => [qw(list)],
order => 3,
gettext_id => "reception mode",
gettext_comment => 'Mail reception mode.',
format => [
'mail', 'notice', 'digest', 'digestplain',
'summary', 'nomail', 'txt', 'urlize',
'not_me'
],
synonym => {'html' => 'mail'},
field_type => 'reception',
occurrence => '0-1', # See default_user_options
not_before => '6.2.67b.2',
},
visibility => {
context => [qw(list)],
order => 4,
gettext_id => "visibility",
gettext_comment => 'Visibility of the subscriber.',
format => ['conceal', 'noconceal'],
field_type => 'visibility',
occurrence => '0-1', # See default_user_options
not_before => '6.2.67b.2',
}
},
occurrence => '0-n'
},
Expand All @@ -2827,6 +2852,7 @@ our %pinfo = (
order => 60.02_1,
group => 'data_source',
gettext_id => 'Owners defined in an external data source',
not_before => '4.2b.5',
format => {
source => {
context => [qw(list)],
Expand All @@ -2839,6 +2865,7 @@ our %pinfo = (
context => [qw(list)],
order => 2,
gettext_id => 'data source parameters',
not_before => '5.0a',
format => '.*',
occurrence => '0-1'
},
Expand All @@ -2847,24 +2874,22 @@ our %pinfo = (
order => 3,
gettext_id => 'profile',
format => ['privileged', 'normal'],
occurrence => '1',
default => 'normal'
occurrence => '0-1', # See default_owner_options
},
reception => {
context => [qw(list)],
order => 4,
gettext_id => 'reception mode',
format => ['mail', 'nomail'],
occurrence => '1',
default => 'mail'
occurrence => '0-1', # See default_owner_options
},
visibility => {
context => [qw(list)],
order => 5,
gettext_id => "visibility",
not_before => '5.4a.6',
format => ['conceal', 'noconceal'],
occurrence => '1',
default => 'noconceal'
occurrence => '0-1', # See default_owner_options
},
},
occurrence => '0-n'
Expand All @@ -2875,6 +2900,7 @@ our %pinfo = (
order => 60.02_2,
group => 'data_source',
gettext_id => 'Moderators defined in an external data source',
not_before => '4.2b.5',
format => {
source => {
context => [qw(list)],
Expand All @@ -2887,6 +2913,7 @@ our %pinfo = (
context => [qw(list)],
order => 2,
gettext_id => 'data source parameters',
not_before => '5.0a',
format => '.*',
occurrence => '0-1'
},
Expand All @@ -2895,16 +2922,15 @@ our %pinfo = (
order => 3,
gettext_id => 'reception mode',
format => ['mail', 'nomail'],
occurrence => '1',
default => 'mail'
occurrence => '0-1', # See default_editor_options
},
visibility => {
context => [qw(list)],
order => 5,
gettext_id => "visibility",
not_before => '5.4a.6',
format => ['conceal', 'noconceal'],
occurrence => '1',
default => 'noconceal'
occurrence => '0-1', # See default_editor_options
}
},
occurrence => '0-n'
Expand Down
15 changes: 14 additions & 1 deletion src/lib/Sympa/DataSource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,23 @@ sub new {
die 'bug in logic. Ask developer' unless ref $list eq 'Sympa::List';
}

# Get default user options from data source definition.
my %defopts;
if (grep { $role eq $_ } qw(member owner editor)) {
%defopts =
map { ($_ => $options{$_}) }
grep { defined $options{$_} }
keys %{$list->get_default_user_options(role => $role)};
}

$options{name} = Sympa::Tools::Text::clip($options{name}, 50)
if 50 < length($options{name} // '');

my $self = $type->_new(%options, _role => $role,);
my $self = $type->_new(
%options,
_role => $role,
default_user_options => {%defopts},
);
$self->{_external} = not($self->isa('Sympa::DataSource::List')
and [split /\@/, $self->{listname}, 2]->[1] eq $list->{'domain'})
if ref $list eq 'Sympa::List';
Expand Down
1 change: 1 addition & 0 deletions src/lib/Sympa/Request/Handler/include.pm
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ sub _update_users {
my @list_of_new_users = map {
my ($email, $gecos) = @$_;
my $user = {
%{$ds->{default_user_options} // {}},
email => $email,
gecos => $gecos,
subscribed => 0,
Expand Down

0 comments on commit 0328681

Please sign in to comment.