Commit 3cc60afd authored by sympa-authors's avatar sympa-authors
Browse files

[G. Bouteille]New feature: add features to families (--add_list, --modify_list, close_family)


git-svn-id: https://subversion.renater.fr/sympa/trunk@2610 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent f4c1fc84
......@@ -47,7 +47,7 @@ Subject: [% FILTER qencode %][%|loc(param0)%]list %1 in status error_config[%END
[%|loc%]The list status has been set to error_config.[%END%]
[%|loc%]Check Sympa log files for more precise information.[%END%]
[% ELSIF type == 'error_family_file' -%]
[% ELSIF type == 'error_copy_file' -%]
Subject: [% FILTER qencode %][%|loc(param0)%]list %1 in status error_config[%END%][%END%]
[%|loc(param0,param1)%]Errors occured while copying family %2 file in list %1 directory.[%END%]
......@@ -104,6 +104,14 @@ Subject: [% FILTER qencode %][%|loc(param0)%]admins update failed for list %1[%E
=======
[%|loc%]Sympa could not include admins from external data sources ; the database or LDAP directory might be unreachable.
Check Sympa log files for more precise information[%END%]
[% ELSIF type == 'modify_list_family' -%]
Subject: [% FILTER qencode %][%|loc(param0)%]list %1 in status error_config[%END%][%END%]
[%|loc(param0,param1)%]Sympa could not modify list %1 (Family %2)[%END%]
[%|loc%]The list status has been set to error_config.[%END%]
[%|loc%]Check Sympa log files for more precise information.[%END%]
[% ELSIF type == 'automatic_bounce_management' -%]
Subject: [% FILTER qencode %][%|loc(list.name)%]List %1 automatic bounce management[%END%][%END%]
......
......@@ -347,7 +347,8 @@ sub _getChildren {
# TEXT_NODE
}elsif ($type == 3) {
my $value = $child->nodeValue;
$value =~ s/(\s)+//;
# $value =~ s/(\s)+//;
$value =~ s/^(\s)+//;
unless ($value eq "") {
$string = $string.$value;
if ($return eq "hash") {
......
This diff is collapsed.
......@@ -1355,6 +1355,7 @@ sub set_status_family_closed {
unless ($self->new_send_notify_to_owner($message,@param)){
&do_log('err','Impossible to send notify to owner informing status family_closed for the list %s',$self->{'name'});
}
# messages : close_list
}
return 1;
}
......@@ -1534,14 +1535,10 @@ sub save_config {
## Update management info
$self->{'admin'}{'serial'}++;
# $self->{'admin'}{'defaults'}{'serial'} = 0;
$self->{'admin'}{'update'} = {'email' => $email,
'date_epoch' => time,
'date' => &POSIX::strftime("%d %b %Y at %H:%M:%S", localtime(time))
};
# $self->{'admin'}{'defaults'}{'update'} = 0;
# $self->{'admin'}{'defaults'}{'family_name'} = 0;
# $self->{'admin'}{'defaults'}{'latest_instantiation'} = 0;
unless (&_save_admin_file($config_file_name, $old_config_file_name, $self->{'admin'})) {
&do_log('info', 'unable to save config file %s', $config_file_name);
......@@ -10420,7 +10417,7 @@ sub get_next_db_log {
return $log;
}
## Close the list (remove from DB, remove aliases, change status to 'closed')
## Close the list (remove from DB, remove aliases, change status to 'closed' or 'family_closed')
sub close {
my ($self, $email, $status) = @_;
......
......@@ -353,12 +353,12 @@ sub create_list{
$list->{'admin'}{'creation'}{'date'} = &POSIX::strftime("%d %b %Y at %H:%M:%S", localtime(time));
$list->{'admin'}{'creation'}{'date_epoch'} = time;
if (defined $param->{'creation_email'}) {
if ($param->{'creation_email'}) {
$list->{'admin'}{'creation'}{'email'} = $param->{'creation_email'};
} else {
$list->{'admin'}{'creation'}{'email'} = $Conf{'listmaster'};
}
if (defined $param->{'status'}) {
if ($param->{'status'}) {
$list->{'admin'}{'status'} = $param->{'status'};
} else {
$list->{'admin'}{'status'} = 'open';
......@@ -451,13 +451,13 @@ sub update_list{
############## ? update
$list->{'admin'}{'creation'}{'date'} = &POSIX::strftime("%d %b %Y at %H:%M:%S", localtime(time));
$list->{'admin'}{'creation'}{'date_epoch'} = time;
if (defined $param->{'creation_email'}) {
if ($param->{'creation_email'}) {
$list->{'admin'}{'creation'}{'email'} = $param->{'creation_email'};
} else {
$list->{'admin'}{'creation'}{'email'} = $Conf{'listmaster'};
}
if (defined $param->{'status'}) {
if ($param->{'status'}) {
$list->{'admin'}{'status'} = $param->{'status'};
} else {
$list->{'admin'}{'status'} = 'open';
......
......@@ -84,6 +84,14 @@ Options:
--instantiate_family=family_name --robot=robot_name < file.xml
: instantiate family_name lists described in the file.xml under robot_name,
the family directory must exist
--add_list=family_name --robot=robot_name < file.xml
: add the list described by the file.xml under robot_name, to the family
family_name.
--modify_list=family_name --robot=robot_name < file.xml
: modify the existing list installed under the robot_name robot and that
belongs to family_name family. The new description is in the file.xml
--close_family=family_name --robot=robot_name
: close lists of family_name family under robot_name.
--close_list=LISTNAME[\@ROBOT] : close a list
--log_level=LEVEL : sets Sympa log level
......@@ -101,7 +109,7 @@ encryption.
my %options;
unless (&GetOptions(\%main::options, 'dump=s', 'debug|d', ,'log_level=s','foreground', 'config|f=s',
'lang|l=s', 'mail|m', 'keepcopy|k=s', 'help', 'version', 'import=s','make_alias_file','lowercase',
'close_list=s','create_list','instantiate_family=s','robot=s')) {
'close_list=s','create_list','instantiate_family=s','robot=s','add_list=s','modify_list=s','close_family=s')) {
&fatal_err("Unknown options.");
}
......@@ -118,7 +126,10 @@ $main::options{'foreground'} = 1 if ($main::options{'debug'} ||
$main::options{'dump'} ||
$main::options{'close_list'} ||
$main::options{'create_list'} ||
$main::options{'instantiate_family'});
$main::options{'instantiate_family'} ||
$main::options{'add_list'} ||
$main::options{'modify_list'} ||
$main::options{'close_family'});
## Batch mode, ie NOT daemon
$main::options{'batch'} = 1 if ($main::options{'dump'} ||
......@@ -129,7 +140,10 @@ $main::options{'foreground'} = 1 if ($main::options{'debug'} ||
$main::options{'lowercase'} ||
$main::options{'close_list'} ||
$main::options{'create_list'} ||
$main::options{'instantiate_family'});
$main::options{'instantiate_family'} ||
$main::options{'add_list'} ||
$main::options{'modify_list'} ||
$main::options{'close_family'});
$log_level = $main::options{'log_level'} if ($main::options{'log_level'});
......@@ -343,9 +357,16 @@ if ($main::options{'dump'}) {
exit 1;
}
unless ($list->close()) {
print STDERR "Could not close list $main::options{'close_list'}\n";
exit 1;
if ($list->{'admin'}{'family_name'}) {
unless($list->set_status_family_closed('close_list',$list->{'name'})) {
print STDERR "Could not close list $main::options{'close_list'}\n";
exit 1;
}
} else {
unless ($list->close()) {
print STDERR "Could not close list $main::options{'close_list'}\n";
exit 1;
}
}
printf STDOUT "List %s has been closed, aliases have been removed\n", $list->{'name'};
......@@ -406,6 +427,114 @@ if ($main::options{'dump'}) {
my $string = $family->get_instantiation_results();
print STDERR $string;
exit 0;
}elsif ($main::options{'add_list'}) {
my $robot;
unless ($robot = $main::options{'robot'}) {
print STDERR $usage_string;
exit 1;
}
my $family_name;
unless ($family_name = $main::options{'add_list'}) {
print STDERR $usage_string;
exit 1;
}
print STDOUT "\n************************************************************\n";
my $family;
unless ($family = new Family($family_name,$robot)) {
print STDERR "The family $family_name does not exist, impossible to add a list\n";
exit 1;
}
my $result;
unless ($result = $family->add_list(\*STDIN)) {
print STDERR "\nImpossible to add a list to the family : action stopped \n";
exit 1;
}
print STDOUT "\n************************************************************\n";
unless (defined $result->{'ok'}) {
print STDERR "$result->{'string_info'}";
print STDERR "\n The action has been stopped because of error :\n";
print STDERR "$result->{'string_error'}";
exit 1;
}
print STDOUT $result->{'string_info'};
exit 0;
}
##########################################
elsif ($main::options{'modify_list'}) {
my $robot;
unless ($robot = $main::options{'robot'}) {
print STDERR $usage_string;
exit 1;
}
my $family_name;
unless ($family_name = $main::options{'modify_list'}) {
print STDERR $usage_string;
exit 1;
}
print STDOUT "\n************************************************************\n";
my $family;
unless ($family = new Family($family_name,$robot)) {
print STDERR "The family $family_name does not exist, impossible to modify the list.\n";
exit 1;
}
my $result;
unless ($result = $family->modify_list(\*STDIN)) {
print STDERR "\nImpossible to modify the family list : action stopped. \n";
exit 1;
}
print STDOUT "\n************************************************************\n";
unless (defined $result->{'ok'}) {
print STDERR "$result->{'string_info'}";
print STDERR "\nThe action has been stopped because of error :\n";
print STDERR "$result->{'string_error'}";
exit 1;
}
print STDOUT $result->{'string_info'};
exit 0;
}
##########################################
elsif ($main::options{'close_family'}) {
my $robot;
unless ($robot = $main::options{'robot'}) {
print STDERR $usage_string;
exit 1;
}
my $family_name;
unless ($family_name = $main::options{'close_family'}) {
print STDERR $usage_string;
exit 1;
}
my $family;
unless ($family = new Family($family_name,$robot)) {
print STDERR "The family $family_name does not exist, impossible family closure\n";
exit 1;
}
my $string;
unless ($string = $family->close()) {
print STDERR "\nImpossible family closure : action stopped \n";
exit 1;
}
print STDOUT $string;
exit 0;
}
......
......@@ -4081,7 +4081,7 @@ sub do_redirect {
#$file =~ s/\.tpl$/\.$list->{'admin'}{'lang'}\.tpl/;
## Look for the template
$param->{'filepath'} = &tools::Sget_filename('etc',$subdir.$file,$robot, $list);
$param->{'filepath'} = &tools::get_filename('etc',$subdir.$file,$robot, $list);
## Default for 'homepage' is 'info'
if (($in{'file'} eq 'homepage') &&
......@@ -6617,7 +6617,7 @@ sub _prepare_data {
if ($restrict) {
&_restrict_values($p->{'value'},$constraint);
}
}
}elsif ($struct->{'datasource'}) {
$p_glob->{'type'} = 'datasource';
......@@ -6704,6 +6704,19 @@ sub _prepare_data {
return $p_glob;
}
## Restrict allowed values in the hash
sub _restrict_values {
my $values = shift; #ref on hash of values
my $allowed = shift; #ref on hash of allowed values
&do_log('debug3', '_restrict_values()');
foreach my $v (keys %{$values}) {
unless (defined $allowed->{$v}) {
delete $values->{$v};
}
}
}
## NOT USED anymore (expect chinese)
sub do_close_list_request {
&wwslog('info', 'do_close_list_request()');
......
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