Commit 4729cff4 authored by sikeda's avatar sikeda
Browse files

[svn] Retrieving several cleanups and additions from trunk.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11962 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 6095d892
......@@ -85,6 +85,7 @@ use SDM;
use Sympa::Session;
use Sympa::SharedDocument;
use tools;
use Sympa::Tools::Daemon;
use Sympa::Tools::Data;
use Sympa::Tools::File;
use Sympa::Tools::Password;
......@@ -125,7 +126,7 @@ unless (Conf::load()) {
 
Log::set_log_level($Conf::Conf{'log_level'});
 
my $daemon_name = Log::set_daemon($0);
my $daemon_name = Sympa::Tools::Daemon::get_daemon_name($0);
 
## Open log
my $log_facility = $Conf::Conf{'log_facility'} || $Conf::Conf{'syslog'};
......@@ -1977,9 +1978,6 @@ Sympa::Alarm->instance->flush(purge => 1);
sub wwslog {
my $facility = shift;
 
# do not log if log level if too high regarding the log requested by user
return if ($Log::levels{$facility} > $Log::log_level);
my $msg = shift;
my $remote = $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'};
my $wwsmsg = '';
......@@ -3015,7 +3013,7 @@ sub check_param_in {
return undef;
}
 
## Gather list configuration informations for further output.
# Gather list configuration information for further output.
$param->{'list'} = $in{'list'};
$param->{'subtitle'} = $list->{'admin'}{'subject'};
$param->{'subscribe'} = $list->{'admin'}{'subscribe'}{'name'};
......@@ -3074,9 +3072,8 @@ sub check_param_in {
my $r_action;
$r_action = $result->{'action'} if (ref($result) eq 'HASH');
$param->{'may_post'} = 1 if ($r_action !~ /reject/);
## If no user logged in, the output can ask for authentification.
} else {
# If no user logged in, the output can ask for authentication.
$param->{'user'}{'email'} = undef;
$param->{'need_login'} = 1;
 
......@@ -3085,8 +3082,8 @@ sub check_param_in {
## Check if this list's messages must be moderated.
$param->{'is_moderated'} = $list->is_moderated();
 
## If the user logged in is a privileged user, gather informations
## relative to administration tasks
# If the user logged in is a privileged user, gather information
# relative to administration tasks.
if ($param->{'is_priv'}) {
$param->{'mod_message'} = $list->get_mod_spool_size();
 
......@@ -6486,7 +6483,7 @@ sub do_auto_signoff {
return Conf::get_robot_conf($robot, 'default_home');
}
$param->{'signing_off_email'} = $in{'email'};
## If OK, return the page displaying the informations to the user.
# If OK, return the page displaying the information to the user.
return 1;
 
}
......@@ -6522,7 +6519,7 @@ sub do_family_signoff_request {
}
$param->{'signing_off_email'} = $in{'email'};
$param->{'family'} = $in{'family'};
## If OK, return the page displaying the informations to the user.
# If OK, return the page displaying the information to the user.
return 1;
 
}
......@@ -13194,8 +13191,8 @@ sub _prepare_edit_form {
$is_form_editable = '1';
}
 
## Store in $p a reference to the hash containing the informations
## relative to the parameter editing.
# Store in $p a reference to the hash containing the information
# relative to the parameter editing.
my $p =
_prepare_data($pname, $pinfo->{$pname}, $list_config->{$pname},
$may_edit, $family);
......
......@@ -559,7 +559,6 @@ sub set_robot_conf {
# Store configs to database
sub conf_2_db {
Log::do_log('debug2', '(%s)', @_);
my $config_file = shift || get_sympa_conf();
my @conf_parameters = @Sympa::ConfDef::params;
......@@ -890,7 +889,7 @@ sub checkfiles {
}
}
update_css();
update_css();
return undef if ($config_err);
return 1;
}
......@@ -2588,11 +2587,13 @@ sub _load_wwsconf {
}
sub update_css {
my (%param) = @_;
my $force = $param{force} if (%param);
my %param = @_;
my $force = $param{force} if %param;
# create or update static CSS files
my $css_updated = undef;
my @robots = ('*',keys %{$Conf{'robots'}});
my @robots = ('*', keys %{$Conf{'robots'}});
foreach my $robot (@robots) {
my $dir = get_robot_conf($robot, 'css_path');
......@@ -2626,7 +2627,7 @@ sub update_css {
## Update the CSS if it is missing or if a new css.tt2 was
## installed
if (!-f $dir . '/' . $css
if ( !-f $dir . '/' . $css
|| (stat($css_tt2_path))[9] > (stat($dir . '/' . $css))[9]
|| $force) {
Log::do_log('notice',
......
......@@ -247,18 +247,10 @@ sub do_connect {
}
}
# return the name of the used daemon
sub set_daemon {
my $daemon_tmp = shift;
my @path = split(/\//, $daemon_tmp);
my $daemon = $path[$#path];
$daemon =~ s/(\.[^\.]+)$//;
return $daemon;
}
# MOVED to Sympa::Tools::Daemon::get_daemon_name().
#sub set_daemon;
sub get_log_date {
my $date_from, my $date_to;
my $sth;
my @dates;
foreach my $query ('MIN', 'MAX') {
......@@ -631,6 +623,7 @@ sub set_log_level {
$log_level = shift;
}
#OBSOLETED: No longer used.
sub get_log_level {
return $log_level;
}
......
......@@ -49,8 +49,6 @@ sub store_last {
Log::do_log('debug2', '');
my ($filename, $newfile);
return unless $list->is_archived();
my $dir = $list->{'dir'} . '/archives';
......@@ -76,8 +74,7 @@ sub list {
Log::do_log('debug', '(%s)', $name);
my ($filename, $newfile);
my (@l, $i);
my (@l, $i);
unless (-d "$name") {
Log::do_log('err', '(%s) Failed, no directory %s', $name, $name);
......@@ -216,18 +213,15 @@ sub exist {
# return path for latest message distributed in the list
sub last_path {
Log::do_log('debug', '(%s)', @_);
my $list = shift;
Log::do_log('debug', '(%s)', $list->{'name'});
return undef unless $list->is_archived();
return undef unless ($list->is_archived());
my $file = $list->{'dir'} . '/archives/last_message';
return $file if -f $file;
return ($list->{'dir'} . '/archives/last_message')
if (-f $list->{'dir'} . '/archives/last_message');
return undef;
}
## Load an archived message, returns the mhonarc metadata
......@@ -297,7 +291,11 @@ sub clean_archive_directory {
foreach my $file (readdir(ARCDIR)) {
next if ($file =~ /^\./);
$files_left_uncleaned++
unless clean_archived_message($robot, undef, $answer->{'cleaned_dir'}.'/'.$file, $answer->{'cleaned_dir'}.'/'.$file);
unless clean_archived_message(
$robot, undef,
$answer->{'cleaned_dir'} . '/' . $file,
$answer->{'cleaned_dir'} . '/' . $file
);
}
closedir DIR;
if ($files_left_uncleaned) {
......
......@@ -205,7 +205,7 @@ sub authentication {
sub ldap_authentication {
my ($robot, $ldap, $auth, $pwd, $whichfilter) = @_;
my ($mesg, $host);
my $mesg;
Log::do_log('debug2', '(%s, %s, %s)', $auth, '****', $whichfilter);
Log::do_log('debug3', 'Password used: %s', $pwd);
......@@ -413,7 +413,6 @@ sub remote_app_check_password {
my $md5 = Digest::MD5::md5_hex($password);
my $vars;
# seach entry for trusted_application in Conf
my @trusted_apps;
......
......@@ -76,7 +76,7 @@ my $time_command;
## my $msg_file;
# command line to process
my $cmd_line;
# key authentification if 'auth' is present in the command line
# key authentication if 'auth' is present in the command line
my $auth;
# boolean says if quiet is in the cmd line
my $quiet;
......@@ -222,9 +222,6 @@ sub lists {
my $sign_mod = shift;
my $message = shift;
my $sympa = Conf::get_robot_conf($robot, 'sympa');
my $host = Conf::get_robot_conf($robot, 'host');
Log::do_log('debug', 'For robot %s, sign_mod %, message %s',
$robot, $sign_mod, $message);
......@@ -778,7 +775,6 @@ sub review {
my $message = shift;
Log::do_log('debug', '(%s, %s, %s)', $listname, $robot, $sign_mod);
my $sympa = Conf::get_robot_conf($robot, 'sympa');
my $user;
my $list = Sympa::List->new($listname, $robot);
......@@ -830,7 +826,7 @@ sub review {
Log::do_log('debug2', 'Auth requested from %s', $sender);
unless (tools::request_auth($list, $sender, 'review')) {
my $error =
"Unable to request authentification for command 'review'";
'Unable to request authentication for command "review"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $listname},
$cmd_line, $sender, $robot);
......@@ -942,8 +938,6 @@ sub verify {
return 'unknown_list';
}
my $user;
$language->set_lang($list->{'admin'}{'lang'});
if ($sign_mod) {
......@@ -1134,7 +1128,7 @@ sub subscribe {
$cmd = "quiet $cmd" if $quiet;
unless (tools::request_auth($list, $sender, $cmd, $comment)) {
my $error =
"Unable to request authentification for command 'subscribe'";
'Unable to request authentication for command "subscribe"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $which},
$cmd_line, $sender, $robot);
......@@ -1256,8 +1250,6 @@ sub info {
Log::do_log('debug', '(%s, %s, %s, %s)',
$listname, $robot, $sign_mod, $message);
my $sympa = Conf::get_robot_conf($robot, 'sympa');
my $list = Sympa::List->new($listname, $robot);
unless ($list) {
Sympa::Report::reject_report_cmd('user', 'no_existing_list',
......@@ -1536,7 +1528,7 @@ sub signoff {
$cmd = "quiet $cmd" if $quiet;
unless (tools::request_auth($list, $to, $cmd)) {
my $error =
"Unable to request authentification for command 'signoff'";
'Unable to request authentication for command "signoff"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $which},
$cmd_line, $sender, $robot);
......@@ -1748,8 +1740,7 @@ sub add {
my $cmd = 'add';
$cmd = "quiet $cmd" if $quiet;
unless (tools::request_auth($list, $sender, $cmd, $email, $comment)) {
my $error =
"Unable to request authentification for command 'add'";
my $error = 'Unable to request authentication for command "add"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $which},
$cmd_line, $sender, $robot);
......@@ -1942,7 +1933,7 @@ sub invite {
unless (
tools::request_auth($list, $sender, 'invite', $email, $comment)) {
my $error =
"Unable to request authentification for command 'invite'";
'Unable to request authentication for command "invite"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $which},
$cmd_line, $sender, $robot);
......@@ -2229,7 +2220,7 @@ sub remind {
if ($listname eq '*') {
unless (tools::request_auth('*', $sender, 'remind')) {
my $error =
"Unable to request authentification for command 'remind'";
'Unable to request authentication for command "remind"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $listname},
$cmd_line, $sender, $robot);
......@@ -2238,7 +2229,7 @@ sub remind {
} else {
unless (tools::request_auth($list, $sender, 'remind')) {
my $error =
"Unable to request authentification for command 'remind'";
'Unable to request authentication for command "remind"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $listname},
$cmd_line, $sender, $robot);
......@@ -2499,8 +2490,7 @@ sub del {
my $cmd = 'del';
$cmd = "quiet $cmd" if $quiet;
unless (tools::request_auth($list, $sender, $cmd, $who)) {
my $error =
"Unable to request authentification for command 'del'";
my $error = 'Unable to request authentication for command "del"';
Sympa::Report::reject_report_cmd('intern', $error,
{'listname' => $which, 'list' => $list},
$cmd_line, $sender, $robot);
......@@ -2524,10 +2514,7 @@ sub del {
return 'not_allowed';
}
## Get gecos before deletion
my $gecos = $user_entry->{'gecos'};
## Really delete and rewrite to disk.
# Really delete and rewrite to disk.
my $u;
unless (
$u = $list->delete_list_member(
......@@ -2775,7 +2762,7 @@ sub set {
############################################################
# distributes the broadcast of a validated moderated message
#
# IN : -$what (+): command parameters : listname(+), authentification key(+)
# IN : -$what (+): command parameters : listname(+), authentication key(+)
# -$robot (+): robot
#
# OUT : 'unknown_list'|'msg_noty_found'| 1 | undef
......@@ -2911,10 +2898,10 @@ sub distribute {
############################################################
# confirm
############################################################
# confirms the authentification of a message for its
# confirms the authentication of a message for its
# distribution on a list
#
# IN : -$what (+): command parameter : authentification key
# IN : -$what (+): command parameter : authentication key
# -$robot (+): robot
#
# OUT : 'wrong_auth'|'msg_not_found'
......@@ -3188,7 +3175,7 @@ sub confirm {
# Refuse and delete a moderated message and notify sender
# by sending template 'reject'
#
# IN : -$what (+): command parameter : listname and authentification key
# IN : -$what (+): command parameter : listname and authentication key
# -$robot (+): robot
#
# OUT : 'unknown_list'|'wrong_auth'| 1 | undef
......@@ -3529,13 +3516,13 @@ sub which {
return 1;
}
################ Function for authentification #######################
################ Function for authentication #######################
##########################################################
# get_auth_method
##########################################################
# Checks the authentification and return method
# used if authentification not failed
# Checks the authentication and return method
# used if authentication not failed
#
# IN :-$cmd (+): current command
# -$email (+): used to compute auth
......@@ -3546,7 +3533,7 @@ sub which {
# -$sign_mod (+): 'smime'| 'dkim' | -
# -$list : ref(List) | -
#
# OUT : 'smime'|'md5'|'dkim'|'smtp' if authentification OK, undef else
# OUT : 'smime'|'md5'|'dkim'|'smtp' if authentication OK, undef else
# | undef
##########################################################
sub get_auth_method {
......
......@@ -142,9 +142,8 @@ sub getHash {
# OUT : -1 or undef
#################################################################
sub _getRequiredElements {
Log::do_log('debug3', @_);
my $self = shift;
Log::do_log('debug3', '');
my $error = 0;
# listname element is obligatory
unless ($self->_getRequiredSingle('listname')) {
......@@ -290,8 +289,7 @@ sub _getChildren {
my $node = shift;
Log::do_log('debug3', '(%s)', $node->nodeName);
my %error_nodes;
## return value
# return value
my $hash = {};
my $string = "";
my $return = "empty"; # "hash", "string", "empty"
......
......@@ -23,10 +23,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package Sympa::Constants;
use strict;
use Exporter;
our @ISA = qw(Exporter);
use strict;
use constant VERSION => '--VERSION--';
use constant USER => '--USER--';
......
......@@ -1129,7 +1129,7 @@ sub db_struct {
sub not_null {
my %not_null;
my %full_db_struct = full_db_struct();
my %db_struct = db_struct();
foreach my $table (keys %full_db_struct) {
foreach my $field (keys %{$full_db_struct{$table}{'fields'}}) {
$not_null{'$field'} =
......@@ -1142,7 +1142,7 @@ sub not_null {
sub autoincrement {
my %autoincrement;
my %full_db_struct = full_db_struct();
my %db_struct = db_struct();
foreach my $table (keys %full_db_struct) {
foreach my $field (keys %{$full_db_struct{$table}{'fields'}}) {
$autoincrement{$table} = $field
......
......@@ -98,7 +98,6 @@ sub probe_db {
return undef;
}
my (%checked, $table);
my $db_type = Conf::get_robot_conf('*', 'db_type');
my $update_db_field_types =
Conf::get_robot_conf('*', 'update_db_field_types') || 'off';
......@@ -144,8 +143,8 @@ sub probe_db {
@tables = ();
}
my ($fields, %real_struct);
## Check required tables
my %real_struct;
# Check required tables
foreach my $t1 (keys %{$db_struct{'mysql'}}) {
my $found;
foreach my $t2 (@tables) {
......
......@@ -359,12 +359,12 @@ sub add_list {
$self, $self->{'robot'}, $abort_on_error);
unless (defined $result) {
push @{$return->{'string_error'}},
"Error during list creation, see logs for more informations";
"Error during list creation, see logs for more information";
return $return;
}
unless (defined $result->{'list'}) {
push @{$return->{'string_error'}},
"Errors : no created list, see logs for more informations";
"Errors : no created list, see logs for more information";
return $return;
}
my $list = $result->{'list'};
......@@ -407,7 +407,7 @@ sub add_list {
$list->set_status_error_config('no_check_rules_family',
$self->{'name'});
push @{$return->{'string_error'}},
"Impossible to check parameters constraint, see logs for more informations. The list is set in status error_config";
"Impossible to check parameters constraint, see logs for more information. The list is set in status error_config";
return $return;
}
......@@ -679,7 +679,7 @@ sub modify_list {
$list->set_status_error_config('no_check_rules_family',
$self->{'name'});
push @{$return->{'string_error'}},
"Impossible to check parameters constraint, see logs for more informations. The list is set in status error_config";
"Impossible to check parameters constraint, see logs for more information. The list is set in status error_config";
return $return;
}
......@@ -1118,7 +1118,7 @@ sub instantiate {
=head2 sub get_instantiation_results()
Returns a string with informations summarizing the instantiation results.
Returns a string with information summarizing the instantiation results.
=head3 Arguments
......@@ -1529,10 +1529,7 @@ sub check_values {
}
foreach my $p_val (@param_values) {
my $found = 0;
## multiple values
# multiple values
if (ref($p_val) eq 'ARRAY') {
foreach my $p (@{$p_val}) {
......@@ -1994,7 +1991,6 @@ sub _split_xml_file {
join(", ", @error)
);
return undef;
my $minor_param = $2;
}
my $listname_elt = shift @children;
my $listname = $listname_elt->textContent();
......@@ -2309,7 +2305,6 @@ sub _get_customizing {
# keep allowed values
foreach my $param (@{$result->{'forbidden'}{'param'}}) {
my $minor_p;
if ($param =~ /^([\w-]+)\.([\w-]+)$/) {
$param = $1;
}
......@@ -2692,12 +2687,10 @@ sub _load_param_constraint_conf {
}
sub create_automatic_list {
my $self = shift;
my %param = @_;
my $auth_level = $param{'auth_level'};
my $sender = $param{'sender'};
my $message = $param{'message'};
my $listname = $param{'listname'};
my $self = shift;
my %param = @_;
my $sender = $param{'sender'};
my $listname = $param{'listname'};
unless ($self->is_allowed_to_create_automatic_lists(%param)) {
Log::do_log(
......
......@@ -687,13 +687,12 @@ sub set_status_family_closed {
## Saves the statistics data to disk.
sub savestats {
Log::do_log('debug2', '(%s)', @_);
my $self = shift;
Log::do_log('debug2', '');
## Be sure the list has been loaded.
my $name = $self->{'name'};
my $dir = $self->{'dir'};
return undef unless ($list_of_lists{$self->{'domain'}}{$name});
# Be sure the list has been loaded.
my $dir = $self->{'dir'};
return undef unless $list_of_lists{$self->{'domain'}}{$self->{'name'}};
unless (ref($self->{'stats'}) eq 'ARRAY') {
Log::do_log('err', 'Incorrect parameter %s', $self->{'stats'});
......@@ -724,11 +723,10 @@ sub savestats {
## msg count.
sub increment_msg_count {
Log::do_log('debug2', '(%s)', @_);
my $self = shift;
Log::do_log('debug2', '(%s)', $self->{'name'});
## Be sure the list has been loaded.
my $name = $self->{'name'};
# Be sure the list has been loaded.
my $file = "$self->{'dir'}/msg_count";
my %count;
......@@ -765,12 +763,10 @@ sub increment_msg_count {
# Returns the number of messages sent to the list
sub get_msg_count {
Log::do_log('debug2', '(%s)', @_);
my $self = shift;
Log::do_log('debug3', "Getting the number of messages for list %s",
$self->{'name'});
## Be sure the list has been loaded.
my $name = $self->{'name'};
# Be sure the list has been loaded.
my $file = "$self->{'dir'}/stats";
my $count = 0;
......@@ -784,18 +780,15 @@ sub get_msg_count {
}
return $count;
}
## last date of distribution message .
sub get_latest_distribution_date {
Log::do_log('debug2', '(%s)', @_);
my $self = shift;
Log::do_log('debug3', '(%s)', $self->{'name'});
## Be sure the list has been loaded.
my $name = $self->{'name'};
# Be sure the list has been loaded.
my $file = "$self->{'dir'}/msg_count";
my %count;
my $latest_date = 0;
unless (open(MSG_COUNT, $file)) {
Log::do_log('debug2', 'Unable to open %s', $file);