Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sympa
sympa
Commits
b582c487
Unverified
Commit
b582c487
authored
Nov 23, 2019
by
IKEDA Soji
Committed by
GitHub
Nov 23, 2019
Browse files
Merge pull request #771 from ikedas/refactor_family by ikedas
Refactor family
parents
ed2c0831
e6897105
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
src/cgi/wwsympa.fcgi.in
View file @
b582c487
...
...
@@ -9735,9 +9735,9 @@ sub do_create_list {
my $spindle = Sympa::Spindle::ProcessRequest->new(
context => $robot,
action => 'create_list',
listname => $in{'listname'},
parameters => {
owner => [
listname => $in{'listname'},
owner => [
{ email => $param->{'user'}{'email'},
gecos => $param->{'user'}{'gecos'},
}
...
...
@@ -16985,8 +16985,7 @@ sub do_create_automatic_list {
my $spindle = Sympa::Spindle::ProcessRequest->new(
context => $family,
action => 'create_automatic_list',
listname => $listname,
parameters => {},
parameters => {listname => $listname},
abort_on_error => 1,
sender => $param->{'user'}{'email'},
md5_check => 1,
...
...
src/lib/Sympa/Config_XML.pm
View file @
b582c487
...
...
@@ -8,6 +8,9 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2019 The Sympa Community. See the AUTHORS.md file
# at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
...
...
@@ -43,9 +46,15 @@ my $log = Sympa::Log->instance;
# -$fh : file handler on the xml file
#########################################
sub
new
{
$log
->
syslog
('
debug2
',
'
(%s, %s)
',
@
_
);
my
$class
=
shift
;
my
$fh
=
shift
;
$log
->
syslog
('
debug2
',
'');
my
$path
=
shift
;
my
$fh
;
unless
(
open
$fh
,
'
<
',
$path
)
{
$log
->
syslog
('
err
',
'
Can
\'
t open %s: $m
',
$path
);
return
bless
{}
=>
$class
;
}
my
$self
=
{};
my
$parser
=
XML::
LibXML
->
new
();
...
...
@@ -54,28 +63,36 @@ sub new {
$self
->
{'
root
'}
=
$doc
->
documentElement
();
bless
$self
,
$class
;
return
$self
;
return
bless
$self
=>
$class
;
}
################################################
# createHash
################################################
# Create a hash used to create a list. Check
# elements unicity when their are not
# declared multiple
#
# IN : -$self
# OUT : -1 or undef
################################################
sub
createHash
{
# Returns the hash structure.
sub
as_hashref
{
$log
->
syslog
('
debug2
',
'
(%s)
',
@
_
);
my
$self
=
shift
;
return
undef
unless
$self
->
{
root
};
return
undef
unless
$self
->
_createHash
;
my
$phash
=
{
%
{
$self
->
{
config
}
||
{}}};
# Compatibility: single topic on 6.2.24 or earlier.
$phash
->
{
topics
}
||=
$phash
->
{
topic
};
# In old documentation "moderator" was single or multiple editors.
my
$mod
=
$phash
->
{
moderator
};
$phash
->
{
editor
}
||=
(
ref
$mod
eq
'
ARRAY
')
?
$mod
:
(
ref
$mod
eq
'
HASH
')
?
[
$mod
]
:
[]
;
return
$phash
;
}
# Create a hash used to create a list. Check elements unicity when their are
# not declared multiple.
# Old name: Sympa::Config_XML::createHash().
sub
_createHash
{
my
$self
=
shift
;
$log
->
syslog
('
debug2
',
'');
unless
(
$self
->
{'
root
'}
->
nodeName
eq
'
list
')
{
$log
->
syslog
('
err
',
"
Config_XML::createHash() : the root element must be called
\"
list
\"
"
);
$log
->
syslog
('
err
',
'
The root element must be called "list"
');
return
undef
;
}
...
...
@@ -86,53 +103,21 @@ sub createHash {
if
(
$self
->
{'
root
'}
->
hasChildNodes
())
{
my
$hash
=
_getChildren
(
$self
->
{'
root
'});
unless
(
defined
$hash
)
{
unless
(
$hash
)
{
$log
->
syslog
('
err
',
'
Error in list elements
');
return
undef
;
}
if
(
ref
(
$hash
)
eq
"
HASH
")
{
foreach
my
$k
(
keys
%$hash
)
{
if
(
$k
eq
"
type
")
{
## the list template creation without family context
$self
->
{'
type
'}
=
$hash
->
{'
type
'};
}
else
{
$self
->
{'
config
'}{
$k
}
=
$hash
->
{
$k
};
}
}
}
elsif
(
$hash
ne
"")
{
# a string
$log
->
syslog
('
err
',
'
Config_XML::createHash() : the list
\'
s children are not homogeneous
'
);
}
elsif
(
ref
$hash
eq
'
HASH
')
{
$self
->
{
config
}
=
{
%$hash
};
}
else
{
# a string
$log
->
syslog
('
err
',
'
The list
\'
s children are not homogeneous
');
return
undef
;
}
}
return
1
;
}
#########################################
# getHash
#########################################
# return the hash structure containing :
# type, config
#
# IN : -$self
# OUT : -$hash
#########################################
sub
getHash
{
my
$self
=
shift
;
$log
->
syslog
('
debug2
',
'');
my
$hash
=
{};
## the list template creation without family context
$hash
->
{'
type
'}
=
$self
->
{'
type
'}
if
(
defined
$self
->
{'
type
'});
$hash
->
{'
config
'}
=
$self
->
{'
config
'};
return
$hash
;
}
############################# PRIVATE METHODS ##############################
# Deprecated: No longer used.
#sub getHash;
#################################################################
# _getRequiredElements
...
...
@@ -246,7 +231,7 @@ sub _getRequiredSingle {
return
undef
;
}
if
(
$nodeName
eq
"
type
"
)
{
if
(
$nodeName
eq
'
type
'
)
{
## the list template creation without family context
my
$value
=
$node
->
textContent
;
...
...
src/lib/Sympa/Family.pm
View file @
b582c487
This diff is collapsed.
Click to expand it.
src/lib/Sympa/List.pm
View file @
b582c487
...
...
@@ -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
(
...
...
src/lib/Sympa/Request/Handler/create_automatic_list.pm
View file @
b582c487
...
...
@@ -4,8 +4,8 @@
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright 2017, 2018 The Sympa Community. See the AUTHORS.md file
at the
# top-level directory of this distribution and at
# Copyright 2017, 2018
, 2019
The Sympa Community. See the AUTHORS.md file
#
at the
top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
...
...
@@ -26,10 +26,12 @@ package Sympa::Request::Handler::create_automatic_list;
use
strict
;
use
warnings
;
use
English
qw(-no_match_vars)
;
use
File::
Copy
qw()
;
use
Sympa
;
use
Sympa::
Aliases
;
use
Conf
;
use
Sympa::
Config_XML
;
use
Sympa::
List
;
use
Sympa::
LockedFile
;
use
Sympa::
Log
;
...
...
@@ -49,14 +51,28 @@ sub _twist {
my
$request
=
shift
;
my
$family
=
$request
->
{
context
};
my
$listname
=
lc
(
$request
->
{
listname
}
||
'');
my
$param
=
$request
->
{
parameters
};
my
$abort_on_error
=
$request
->
{
abort_on_error
};
my
$robot_id
=
$family
->
{'
robot
'};
my
$path
;
die
'
bug in logic. Ask developer
'
unless
ref
$family
eq
'
Sympa::Family
';
$family
->
{'
state
'}
=
'
no_check
';
if
(
$param
->
{
file
})
{
$path
=
$param
->
{
file
};
# Get list data
$param
=
Sympa::
Config_XML
->
new
(
$path
)
->
as_hashref
;
unless
(
$param
)
{
$log
->
syslog
('
err
',
"
Error in representation data with these xml data
");
$self
->
add_stash
(
$request
,
'
user
',
'
XXX
');
return
undef
;
}
}
my
$listname
=
lc
$param
->
{
listname
};
# Check new listname.
my
@stash
=
Sympa::Aliases::
check_new_listname
(
$listname
,
$robot_id
);
if
(
@stash
)
{
...
...
@@ -75,7 +91,6 @@ sub _twist {
my
$family_config
=
Conf::
get_robot_conf
(
$robot_id
,
'
automatic_list_families
');
$param
->
{'
family_config
'}
=
$family_config
->
{
$family
->
{'
name
'}};
$param
->
{'
listname
'}
=
$listname
;
my
$config
=
'';
my
$template
=
...
...
@@ -212,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
;
...
...
@@ -224,9 +243,10 @@ sub _twist {
$list
->
restore_users
('
owner
');
$list
->
restore_users
('
editor
');
if
(
$listname
ne
$request
->
{
listname
})
{
$self
->
add_stash
(
$request
,
'
notice
',
'
listname_lowercased
');
}
#FIXME
#if ($listname ne $request->{listname}) {
# $self->add_stash($request, 'notice', 'listname_lowercased');
#}
## Create shared if required.
#if (defined $list->{'admin'}{'shared_doc'}) {
...
...
@@ -272,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
',
...
...
@@ -290,15 +308,23 @@ sub _twist {
{
errors
=>
$error
});
}
# Copy files in the list directory : xml file
if
(
$path
and
$path
ne
$list
->
{'
dir
'}
.
'
/instance.xml
')
{
unless
(
File::Copy::
copy
(
$path
,
$list
->
{'
dir
'}
.
'
/instance.xml
'))
{
$list
->
set_status_error_config
('
error_copy_file
',
$family
->
{'
name
'});
$self
->
add_stash
(
$request
,
'
intern
');
$log
->
syslog
('
err
',
'
Impossible to copy the XML file in the list directory
');
}
}
## Synchronize list members if required
if
(
$list
->
has_include_data_sources
())
{
$log
->
syslog
('
notice
',
"
Synchronizing list members...
");
$list
->
sync_include
();
}
## END
$family
->
{'
state
'}
=
'
normal
';
return
1
;
}
...
...
src/lib/Sympa/Request/Handler/create_list.pm
View file @
b582c487
...
...
@@ -4,8 +4,8 @@
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright 2017, 2018 The Sympa Community. See the AUTHORS.md file
at the
# top-level directory of this distribution and at
# Copyright 2017, 2018
, 2019
The Sympa Community. See the AUTHORS.md file
#
at the
top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
...
...
@@ -31,6 +31,7 @@ use English qw(-no_match_vars);
use
Sympa
;
use
Sympa::
Aliases
;
use
Conf
;
use
Sympa::
Config_XML
;
use
Sympa::
List
;
use
Sympa::
LockedFile
;
use
Sympa::
Log
;
...
...
@@ -49,12 +50,28 @@ sub _twist {
my
$request
=
shift
;
my
$robot_id
=
$request
->
{
context
};
my
$listname
=
lc
(
$request
->
{
listname
}
||
'');
my
$param
=
$request
->
{
parameters
};
my
$pending
=
$request
->
{
pending
};
my
$notify
=
$request
->
{
notify
};
my
$sender
=
$request
->
{
sender
};
my
$path
;
if
(
$param
->
{
file
})
{
$path
=
$param
->
{
file
};
# Get list data
$param
=
Sympa::
Config_XML
->
new
(
$path
)
->
as_hashref
;
unless
(
$param
)
{
$log
->
syslog
('
err
',
"
Error in representation data with these xml data
");
$self
->
add_stash
(
$request
,
'
user
',
'
XXX
');
return
undef
;
}
}
my
$listname
=
lc
$param
->
{
listname
};
# Obligatory parameters.
foreach
my
$arg
(
qw(subject template topics)
)
{
unless
(
defined
$param
->
{
$arg
}
and
$param
->
{
$arg
}
=~
/\S/
)
{
...
...
@@ -211,9 +228,10 @@ sub _twist {
$list
->
restore_users
('
owner
');
$list
->
restore_users
('
editor
');
if
(
$listname
ne
$request
->
{
listname
})
{
$self
->
add_stash
(
$request
,
'
notice
',
'
listname_lowercased
');
}
#FIXME
#if ($listname ne $request->{listname}) {
# $self->add_stash($request, 'notice', 'listname_lowercased');
#}
if
(
$list
->
{'
admin
'}{'
status
'}
eq
'
open
')
{
# Install new aliases.
...
...
src/lib/Sympa/Request/Handler/update_automatic_list.pm
View file @
b582c487
...
...
@@ -4,8 +4,8 @@
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright 2018 The Sympa Community. See the AUTHORS.md file
at the
# top-level directory of this distribution and at
# Copyright 2018
, 2019
The Sympa Community. See the AUTHORS.md file
#
at the
top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
...
...
@@ -26,9 +26,11 @@ package Sympa::Request::Handler::update_automatic_list;
use
strict
;
use
warnings
;
use
English
qw(-no_match_vars)
;
use
File::
Copy
qw()
;
use
Sympa
;
use
Conf
;
use
Sympa::
Config_XML
;
use
Sympa::
List
;
use
Sympa::
LockedFile
;
use
Sympa::
Log
;
...
...
@@ -51,6 +53,61 @@ sub _twist {
my
$param
=
$request
->
{
parameters
};
my
$robot_id
=
$family
->
{'
robot
'};
my
$path
;
if
(
$param
->
{
file
})
{
$path
=
$param
->
{
file
};
# get list data
$param
=
Sympa::
Config_XML
->
new
(
$path
)
->
as_hashref
;
unless
(
$param
)
{
$log
->
syslog
('
err
',
"
Error in representation data with these xml data
");
$self
->
add_stash
(
$request
,
'
user
',
'
XXX
');
return
undef
;
}
}
# getting list
if
(
$list
and
$param
->
{
listname
})
{
unless
(
$list
->
get_id
eq
sprintf
('
%s@%s
',
lc
$param
->
{
listname
},
$family
->
{'
robot
'}))
{
$log
->
syslog
('
err
',
'
The list %s and list name %s mismatch
',
$list
,
$param
->
{
listname
});
$self
->
add_stash
(
$request
,
'
user
',
'
XXX
');
return
undef
;
}
}
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
',
$param
->
{
listname
});
$self
->
add_stash
(
$request
,
'
user
',
'
XXX
');
return
undef
;
}
## check family name
if
(
defined
$list
->
{'
admin
'}{'
family_name
'})
{
unless
(
$list
->
{'
admin
'}{'
family_name
'}
eq
$family
->
{'
name
'})
{
$log
->
syslog
('
err
',
"
The list
$list
->{'name'} already belongs to family
$list
->{'admin'}{'family_name'}.
"
);
$self
->
add_stash
(
$request
,
'
user
',
'
listname_already_used
');
return
undef
;
}
}
else
{
$log
->
syslog
('
err
',
"
The orphan list
$list
->{'name'} already exists.
");
$self
->
add_stash
(
$request
,
'
user
',
'
listname_already_used
');
return
undef
;
}
# Get allowed and forbidden list customizing.
my
$custom
=
_get_customizing
(
$family
,
$list
);
unless
(
defined
$custom
)
{
...
...
@@ -173,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
;
...
...
@@ -270,6 +331,43 @@ sub _twist {
[
$family
->
{'
name
'},
$forbidden_param
]);
}
# info parameters
$list
->
{'
admin
'}{'
latest_instantiation
'}{'
email
'}
=
Sympa::
get_address
(
$family
,
'
listmaster
');
$list
->
{'
admin
'}{'
latest_instantiation
'}{'
date_epoch
'}
=
time
;
$list
->
save_config
(
Sympa::
get_address
(
$family
,
'
listmaster
'));
$list
->
{'
family
'}
=
$family
;
# Check param_constraint.conf
my
$error
=
$family
->
check_param_constraint
(
$list
);
unless
(
defined
$error
)
{
$list
->
set_status_error_config
('
no_check_rules_family
',
$family
->
{'
name
'});
$self
->
add_stash
(
$request
,
'
intern
');
$log
->
syslog
('
err
',
'
Impossible to check parameters constraint
');
return
undef
;
}
if
(
ref
$error
eq
'
ARRAY
')
{
$list
->
set_status_error_config
('
no_respect_rules_family
',
$family
->
{'
name
'});
$self
->
add_stash
(
$request
,
'
user
',
'
not_respect_rules_family
',
{
errors
=>
$error
});
$log
->
syslog
('
err
',
'
The list does not respect the family rules : %s
',
join
'
,
',
@
{
$error
});
}
# Copy files in the list directory : xml file
if
(
$path
and
$path
ne
$list
->
{'
dir
'}
.
'
/instance.xml
')
{
unless
(
File::Copy::
copy
(
$path
,
$list
->
{'
dir
'}
.
'
/instance.xml
'))
{
$list
->
set_status_error_config
('
error_copy_file
',
$family
->
{'
name
'});
$self
->
add_stash
(
$request
,
'
intern
');
$log
->
syslog
('
err
',
'
Impossible to copy the XML file in the list directory
');
}
}
return
1
;
}
...
...
src/lib/Sympa/Spindle/ProcessAutomatic.pm
View file @
b582c487
...
...
@@ -247,8 +247,7 @@ sub _twist {
my
$spindle_req
=
Sympa::Spindle::
ProcessRequest
->
new
(
context
=>
$dyn_family
,
action
=>
'
create_automatic_list
',
listname
=>
$listname
,
parameters
=>
{},
parameters
=>
{
listname
=>
$listname
},
sender
=>
$sender
,
smime_signed
=>
$message
->
{'
smime_signed
'},
md5_check
=>
$message
->
{'
md5_check
'},
...
...
src/lib/Sympa/Upgrade.pm
View file @
b582c487
...
...
@@ -32,6 +32,7 @@ use warnings;
use
Cwd
qw()
;
use
Encode
qw()
;
use
English
qw(-no_match_vars)
;
use
File::
Copy
qw()
;
use
MIME::
Base64
qw()
;
use
Time::
Local
qw()
;
...
...
src/lib/Sympa/WWW/SOAP.pm
View file @
b582c487
...
...
@@ -8,8 +8,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018 The Sympa Community. See the AUTHORS.md file
at the
# top-level directory of this distribution and at
# Copyright 2017, 2018
, 2019
The Sympa Community. See the AUTHORS.md file
#
at the
top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
...
...
@@ -617,9 +617,9 @@ sub createList {
my
$spindle
=
Sympa::Spindle::
ProcessRequest
->
new
(
context
=>
$robot
,
action
=>
'
create_list
',
listname
=>
$listname
,
parameters
=>
{
owner
=>
[
listname
=>
$listname
,
owner
=>
[
{
email
=>
$sender
,
gecos
=>
(
$user
?
$user
->
{
gecos
}
:
undef
),
}
...
...
src/sbin/sympa.pl.in
View file @
b582c487
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment