Commit 82e1d2d3 authored by sikeda's avatar sikeda
Browse files

[change] 'include_sympa_list' parameter obsoletes 'include_list' parameter in...

[change] 'include_sympa_list' parameter obsoletes 'include_list' parameter in list config and named data sources.  Older one may still be used and mapped to newer one internally.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12810 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 49b9c2ba
......@@ -103,8 +103,8 @@
[%|helploc%]This paragraph defines parameters for a two-level query returning a list of subscribers. Usually the first-level query returns a list of DNs and the second-level queries convert the DNs into e-mail addresses. This feature requires the Net::LDAP (perlldap) PERL module.[%END%]
[% ELSIF p.key == 'include_ldap_query' %]
[%|helploc%]This paragraph defines parameters for a query returning a list of subscribers. This feature requires the Net::LDAP (perlldap) PERL module.[%END%]
[% ELSIF p.key == 'include_list' %]
[%|helploc%]Include subscribers from other list. All subscribers of list listname become subscribers of the current list. You may include as many lists as required, using one include_list listname line for each included list. Any list at all may be included; you may therefore include lists which are also defined by the inclusion of other lists. Be careful, however, not to include list A in list B and then list B in list A, since this will give rise to an infinite loop.[%END%]
[% ELSIF p.key == 'include_sympa_list' %]
[%|helploc%]Include subscribers from other list. All subscribers of list listname become subscribers of the current list. You may include as many lists as required, using one include_sympa_list paragraph for each included list. Any list at all may be included; you may therefore include lists which are also defined by the inclusion of other lists. Be careful, however, not to include list A in list B and then list B in list A, since this will give rise to an infinite loop.[%END%]
[% ELSIF p.key == 'include_remote_sympa_list' %]
[%|helploc%]Sympa can contact another Sympa service using HTTPS to fetch a remote list in order to include each member of a remote list as subscriber. You may include as many lists as required, using one include_remote_sympa_list paragraph for each included list. Be careful, however, not to give rise to an infinite loop resulting from cross includes.[%END%]<br /><br />
[%|helploc%]For this operation, one Sympa site acts as a server while the other one acs as client. On the server side, the only setting needed is to give permission to the remote Sympa to review the list. This is controlled by the review scenario.[%END%]
......
......@@ -778,8 +778,6 @@ sub rename_list {
}
# If list is included by another list, then it cannot be renamed.
# TODO : we should also check owner_include and editor_include, but a bit
# more tricky.
unless ($param{'mode'} and $param{'mode'} eq 'copy') {
if ($list->is_included) {
$log->syslog('err',
......@@ -1601,15 +1599,15 @@ sub change_user_email {
my $user_entry = $list->get_list_member($in{'current_email'});
if ($user_entry->{'included'} == 1) {
## Check the type of data sources
## If only include_list of local mailing lists, then no problem
## Otherwise, notify list owner
## We could also force a sync_include for local lists
# Check the type of data sources.
# If only include_sympa_list of local mailing lists, then no
# problem. Otherwise, notify list owner.
# We could also force a sync_include for local lists.
my $use_external_data_sources;
foreach my $datasource_id (split(/,/, $user_entry->{'id'})) {
my $datasource = $list->search_datasource($datasource_id);
if ( !defined $datasource
or $datasource->{'type'} ne 'include_list'
or $datasource->{'type'} ne 'include_sympa_list'
or ( $datasource->{'def'} =~ /\@(.+)$/
and $1 ne $robot_id)
) {
......
......@@ -68,10 +68,10 @@ my @sources_providing_listmembers = qw/
include_file
include_ldap_2level_query
include_ldap_query
include_list
include_remote_file
include_remote_sympa_list
include_sql_query
include_sympa_list
/;
#XXX include_admin
......@@ -4806,21 +4806,10 @@ sub _include_users_list {
my $tied = shift;
my $robot = $self->{'domain'};
my $listname_regex =
Sympa::Regexps::listname() . '(?:\@'
. Sympa::Regexps::host()
. ')?';
my $filter_regex = '(' . $listname_regex . ')\s+filter\s+(.+)';
my ($source_id, $filter);
if ($incl =~ /\A$filter_regex/) {
($source_id, $filter) = (lc $1, $2);
} else {
$source_id = lc $incl;
}
my $source_id = lc $incl->{listname};
$source_id = sprintf '%s@%s', $source_id, $self->{'domain'}
unless 0 < index($source_id, '@');
my $filter = $incl->{filter};
my $id = Sympa::Datasource::_get_datasource_id($incl);
my $total = 0;
......@@ -6085,12 +6074,12 @@ sub _load_list_members_from_include {
push @errors,
{'type' => $type, 'name' => $incl->{'name'}};
}
} elsif ($type eq 'include_list') {
} elsif ($type eq 'include_sympa_list') {
if ($self->_inclusion_loop('member', $incl, 'recursive')) {
$log->syslog(
'err',
'Loop detection in list inclusion: could not include again %s in list %s',
$incl,
$incl->{name},
$self
);
} else {
......@@ -6099,7 +6088,7 @@ sub _load_list_members_from_include {
$self->{'admin'}{'default_user_options'});
unless (defined $included) {
push @errors,
{'type' => $type, 'name' => $incl};
{'type' => $type, 'name' => $incl->{name}};
} else {
push @depend_on, $incl;
}
......@@ -6137,18 +6126,7 @@ sub _load_list_members_from_include {
exclusions => \@ex_sources,
depend_on => [Sympa::Tools::Data::sort_uniq(map
{
my $listname_regex =
Sympa::Regexps::listname() . '(?:\@'
. Sympa::Regexps::host()
. ')?';
my $filter_regex = '(' . $listname_regex . ')\s+filter\s+(.+)';
my $source_id;
if (/\A$filter_regex/) {
$source_id = lc $1;
} else {
$source_id = lc $_;
}
my $source_id = lc $_->{listname};
$source_id = sprintf '%s@%s', $source_id, $self->{'domain'}
unless 0 < index($source_id, '@');
$source_id
......@@ -6311,13 +6289,13 @@ sub _load_list_admin_from_include {
$included =
$self->_include_users_remote_sympa_list(\%admin_users,
$incl, $dir, $self->{'domain'}, \%option);
} elsif ($type eq 'include_list') {
} elsif ($type eq 'include_sympa_list') {
if ($self->_inclusion_loop($role, $incl, 0)) {
#FIXME: Required?
$log->syslog(
'err',
'Loop detection in list inclusion: could not include again %s in %s of %s',
$incl,
$incl->{name},
$role,
$self
);
......@@ -6326,7 +6304,7 @@ sub _load_list_admin_from_include {
\%admin_users, $incl, \%option);
unless (defined $included) {
# push @errors,
# {'type' => $type, 'name' => $incl};
# {'type' => $type, 'name' => $incl->{name}};
} else {
push @depend_on, $incl;
}
......@@ -6362,17 +6340,7 @@ sub _load_list_admin_from_include {
users => \%admin_users,
depend_on => [Sympa::Tools::Data::sort_uniq(map
{
my $listname_regex =
Sympa::Regexps::listname() . '(?:\@'
. Sympa::Regexps::host()
. ')?'; my $filter_regex = '(' . $listname_regex . ')\s+filter\s+(.+)';
my $source_id;
if (/\A$filter_regex/) {
$source_id = lc $1;
} else {
$source_id = lc $_;
}
my $source_id = lc $_->{listname};
$source_id = sprintf '%s@%s', $source_id, $self->{'domain'}
unless 0 < index($source_id, '@');
$source_id
......@@ -6391,8 +6359,10 @@ sub _load_include_admin_user_file {
my $robot = $self->{'domain'};
my $pinfo = {};
@{$pinfo}{@sources_providing_listmembers} =
@{Sympa::Robot::list_params($robot) || {}}{@sources_providing_listmembers};
# 'include_list' is kept for comatibility with 6.2.15 or earlier.
my @sources = (@sources_providing_listmembers, 'include_list');
@{$pinfo}{@sources} =
@{Sympa::Robot::list_params($robot) || {}}{@sources};
my %include;
my (@paragraphs);
......@@ -6615,6 +6585,8 @@ sub _load_include_admin_user_file {
}
}
_load_include_admin_user_postprocess(\%include);
return \%include;
}
......@@ -7524,7 +7496,7 @@ sub is_update_param {
}
}
# Checks if adding a include_list setting will cause inclusion loop.
# Checks if adding a include_sympa_list setting will cause inclusion loop.
#FIXME:Isn't there any more efficient way to explore DAG?
sub _inclusion_loop {
my $self = shift;
......@@ -7532,18 +7504,7 @@ sub _inclusion_loop {
my $incl = shift;
my $recursive = shift;
my $listname_regex =
Sympa::Regexps::listname() . '(?:\@'
. Sympa::Regexps::host()
. ')?';
my $filter_regex = '(' . $listname_regex . ')\s+filter\s+(.+)';
my ($source_id, $filter);
if ($incl =~ /\A$filter_regex/) {
($source_id, $filter) = (lc $1, $2);
} else {
$source_id = lc $incl;
}
my $source_id = lc $incl->{listname};
$source_id = sprintf '%s@%s', $source_id, $self->{'domain'}
unless 0 < index($source_id, '@');
my $target_id = $self->get_id;
......@@ -8963,6 +8924,7 @@ sub _load_list_config_file {
}
$self->_load_list_config_postprocess(\%admin);
_load_include_admin_user_postprocess(\%admin);
return \%admin;
}
......@@ -9059,6 +9021,46 @@ sub _load_list_config_postprocess {
}
}
# Proprocessing particular parameters specific to datasources.
sub _load_include_admin_user_postprocess {
my $config_hash = shift;
# The include_list was obsoleted by include_sympa_list on 6.2.16.
if ($config_hash->{'include_list'}) {
my $listname_regex =
Sympa::Regexps::listname() . '(?:\@'
. Sympa::Regexps::host()
. ')?';
my $filter_regex = '(' . $listname_regex . ')\s+filter\s+(.+)';
$config_hash->{'include_sympa_list'} ||= [];
foreach my $incl (@{$config_hash->{'include_list'} || []}) {
next unless defined $incl and $incl =~ /\S/;
my ($listname, $filter);
if ($incl =~ /\A$filter_regex/) {
($listname, $filter) = (lc $1, $2);
undef $filter unless $filter =~ /\S/;
} elsif ($incl =~ /\A$listname_regex\z/) {
$listname = lc $incl;
} else {
$log->syslog('err',
'Malformed value "%s" in include_list parameter. Skipped',
$incl);
next;
}
push @{$config_hash->{'include_sympa_list'}}, {
name => sprintf('include_list %s', $incl),
listname => $listname,
filter => $filter,
};
}
delete $config_hash->{'include_list'};
delete $config_hash->{'defaults'}{'include_sympa_list'};
}
}
## Save a config file
sub _save_list_config_file {
$log->syslog('debug3', '(%s, %s, %s)', @_);
......
......@@ -41,7 +41,7 @@ our @param_order =
host lang process_archive web_archive archive digest digest_max_size available_user_options
default_user_options msg_topic msg_topic_keywords_apply_on msg_topic_tagging reply_to_header reply_to forced_reply_to *
verp_rate tracking welcome_return_path remind_return_path user_data_source include_file include_remote_file
include_list include_remote_sympa_list include_ldap_query
include_sympa_list include_remote_sympa_list include_ldap_query
include_ldap_2level_query include_sql_query include_voot_group ttl distribution_ttl creation update
status serial custom_attribute include_ldap_ca include_ldap_2level_ca include_sql_ca);
......@@ -958,6 +958,33 @@ our %pinfo = (
'format' => Sympa::Regexps::listname() . '(\@'
. Sympa::Regexps::host()
. ')?(\s+filter\s+.+)?',
'occurrence' => '0-n',
'obsolete' => 1, # <= 6.2.15.
},
'include_sympa_list' => {
'group' => 'data_source',
'gettext_id' => "List inclusion",
'format' => {
'name' => {
'order' => 1,
'gettext_id' => "short name for this source",
'format' => '.+',
'length' => 15
},
'listname' => {
'order' => 2,
'gettext_id' => "list name to include",
'format' => Sympa::Regexps::listname() . '(\@'
. Sympa::Regexps::host() . ')?',
'occurrence' => '1'
},
'filter' => {
'order' => 3,
'gettext_id' => "filter definition",
'format' => '.*'
},
},
'occurrence' => '0-n'
},
......
......@@ -497,39 +497,36 @@ sub upgrade {
close BOUNCEDIR;
}
## Update lists config using 'include_list'
# Update lists config using 'include_sympa_list'
if (lower_version($previous_version, '5.2a.1')) {
$log->syslog('notice',
'Update lists config using include_list parameter...');
'Update lists config using include_sympa_list parameter...');
my $all_lists = Sympa::List::get_lists('*');
foreach my $list (@$all_lists) {
if (defined $list->{'admin'}{'include_list'}) {
my $include_lists = $list->{'admin'}{'include_list'};
my @include_lists =
@{$list->{'admin'}{'include_sympa_list'} || []};
my $changed = 0;
foreach my $index (0 .. $#{$include_lists}) {
my $incl = $include_lists->[$index];
my $incl_list = Sympa::List->new($incl);
foreach my $incl (@include_lists) {
# Search for the list if robot is not specified.
my $incl_list = Sympa::List->new($incl->{listname});
if (defined $incl_list
if ($incl_list
and $incl_list->{'domain'} ne $list->{'domain'}) {
$log->syslog(
'notice',
'Update config file of list %s, including list %s',
$list->get_list_id(),
$incl_list->get_list_id()
$list->get_id,
$incl_list->get_id
);
$include_lists->[$index] = $incl_list->get_list_id();
$incl->{listname} = $incl_list->get_id;
$changed = 1;
}
}
if ($changed) {
$list->{'admin'}{'include_list'} = $include_lists;
$list->save_config('listmaster@' . $list->{'domain'});
$list->{'admin'}{'include_sympa_list'} = [@include_lists];
$list->save_config(Sympa::get_address($list, 'listmaster'));
}
}
}
}
......
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