Commit e6897105 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Family: removed 'state' attribute.

parent 6a28df13
......@@ -157,10 +157,6 @@ sub new {
## hash of parameters constraint
$self->{'param_constraint_conf'} = undef;
## state of the family for the use of check_param_constraint : 'no_check'
## or 'normal'
## check_param_constraint only works in state "normal"
$self->{'state'} = 'normal';
return $self;
}
......@@ -184,16 +180,9 @@ sub new {
#sub get_instantiation_results;
sub check_param_constraint {
$log->syslog('debug2', '(%s, %s)', @_);
my $self = shift;
my $list = shift;
$log->syslog('debug2', '(%s, %s)', $self->{'name'}, $list->{'name'});
if ($self->{'state'} and $self->{'state'} eq 'no_check') {
# because called by load(called by new that is called by instantiate)
# it is not yet the time to check param constraint,
# it will be called later by instantiate
return 1;
}
my @error;
......@@ -778,6 +767,7 @@ Base dire4ctory of the family.
=item {state}
Obsoleted.
TBD.
=back
......
......@@ -981,8 +981,9 @@ sub load {
## check param_constraint.conf if belongs to a family and the config
## has been loaded
if (defined $admin->{'family_name'}
&& ($admin->{'status'} ne 'error_config')) {
if ( not $options->{'no_check_family'}
and defined $admin->{'family_name'}
and $admin->{'status'} ne 'error_config') {
my $family;
unless ($family = $self->get_family()) {
$log->syslog(
......
......@@ -72,8 +72,6 @@ sub _twist {
}
}
$family->{'state'} = 'no_check';
my $listname = lc $param->{listname};
# Check new listname.
my @stash = Sympa::Aliases::check_new_listname($listname, $robot_id);
......@@ -229,8 +227,12 @@ sub _twist {
## Create list object
my $list;
unless ($list =
Sympa::List->new($listname, $robot_id, {skip_sync_admin => 1})) {
unless (
$list = Sympa::List->new(
$listname, $robot_id,
{skip_sync_admin => 1, no_check_family => 1}
)
) {
$log->syslog('err', 'Unable to create list %s', $listname);
$self->add_stash($request, 'intern');
return undef;
......@@ -290,10 +292,8 @@ sub _twist {
$list->save_config(Sympa::get_address($family, 'listmaster'));
$list->{'family'} = $family;
## check param_constraint.conf
$family->{'state'} = 'normal';
# Check param_constraint.conf
my $error = $family->check_param_constraint($list);
$family->{'state'} = 'no_check';
unless (defined $error) {
$list->set_status_error_config('no_check_rules_family',
......@@ -325,9 +325,6 @@ sub _twist {
$list->sync_include();
}
## END
$family->{'state'} = 'normal';
return 1;
}
......
......@@ -76,9 +76,14 @@ sub _twist {
$self->add_stash($request, 'user', 'XXX');
return undef;
}
} elsif ($list
or ($list = Sympa::List->new($param->{listname}, $family->{'robot'}, {just_try => 1})))
{
} elsif (
$list
or ($list = Sympa::List->new(
$param->{listname}, $family->{'robot'},
{just_try => 1, no_check_family => 1}
)
)
) {
$param->{listname} = $list->{'name'};
} else {
$log->syslog('err', 'The list "%s" does not exist',
......@@ -225,8 +230,12 @@ sub _twist {
## Create list object
my $listname = $list->{'name'};
unless ($list =
Sympa::List->new($listname, $robot_id, {skip_sync_admin => 1})) {
unless (
$list = Sympa::List->new(
$listname, $robot_id,
{skip_sync_admin => 1, no_check_family => 1}
)
) {
$log->syslog('err', 'Unable to create list %s', $listname);
$self->add_stash($request, 'intern');
return undef;
......@@ -329,10 +338,8 @@ sub _twist {
$list->save_config(Sympa::get_address($family, 'listmaster'));
$list->{'family'} = $family;
## check param_constraint.conf
$family->{'state'} = 'normal';
# Check param_constraint.conf
my $error = $family->check_param_constraint($list);
$family->{'state'} = 'no_check';
unless (defined $error) {
$list->set_status_error_config('no_check_rules_family',
......
......@@ -917,8 +917,6 @@ elsif ($main::options{'modify_list'}) {
exit 1;
}
$family->{'state'} = 'no_check'; #FIXME
# list config family updating
my $spindle = Sympa::Spindle::ProcessRequest->new(
context => $family,
......@@ -932,8 +930,6 @@ elsif ($main::options{'modify_list'}) {
exit 1;
}
$family->{'state'} = 'normal'; #FIXME
exit 0;
}
......@@ -1242,12 +1238,12 @@ sub instantiate {
## all the description variables are emptied.
_initialize_instantiation($family);
## set impossible checking (used by list->load)
$family->{'state'} = 'no_check';
## get the currently existing lists in the family
my $previous_family_lists =
{(map { $_->{name} => $_ } @{Sympa::List::get_lists($family) || []})};
my $previous_family_lists = {
( map { $_->{name} => $_ }
@{Sympa::List::get_lists($family, no_check_family => 1) || []}
)
};
## Splits the family description XML file into a set of list description
## xml files
......@@ -1279,7 +1275,8 @@ sub instantiate {
# EACH FAMILY LIST
foreach my $listname (@$list_to_generate) {
my $path = $family->{'dir'} . '/' . $listname . '.xml';
my $list = Sympa::List->new($listname, $family->{'robot'});
my $list = Sympa::List->new($listname, $family->{'robot'},
{no_check_family => 1});
if ($list) {
## LIST ALREADY EXISTING
......@@ -1316,7 +1313,8 @@ sub instantiate {
next;
}
$list = Sympa::List->new($listname, $family->{'robot'});
$list = Sympa::List->new($listname, $family->{'robot'},
{no_check_family => 1});
## aliases
if (grep { $_->[1] eq 'notice' and $_->[2] eq 'auto_aliases' }
......@@ -1347,7 +1345,9 @@ sub instantiate {
## PREVIOUS LIST LEFT
foreach my $l (keys %{$previous_family_lists}) {
my $list;
unless ($list = Sympa::List->new($l, $family->{'robot'})) {
unless ($list =
Sympa::List->new($l, $family->{'robot'}, {no_check_family => 1}))
{
push(@{$family->{'errors'}{'previous_list'}}, $l);
next;
}
......@@ -1396,7 +1396,7 @@ sub instantiate {
}
}
}
$family->{'state'} = 'normal';
return 1;
}
......
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