Commit 464c3853 authored by sikeda's avatar sikeda
Browse files

[svn] (con'd r10649) Retrieving layout changes done on trunk (#2/3).

Exceptions:
- Several functions in List were moved to Robot.
- SympaTransport was renamed to Sympa::SOAP::Transport.

Following files won't be renamed at present:
  Log.pm, SDM.pm, tools.pm, tt2.pm, wwslib.pm


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11273 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 1379700a
......@@ -30,7 +30,7 @@ use Getopt::Long;
use Conf;
use Sympa::Constants;
use List;
use Sympa::List;
use SDM;
my %month_idx = qw(jan 1
......@@ -89,7 +89,7 @@ SDM::probe_db();
chdir $Conf::Conf{'home'};
my $list = List->new($listname, $robot)
my $list = Sympa::List->new($listname, $robot)
or die 'Cannot create List object';
my $home_sympa;
......
......@@ -19,7 +19,7 @@ use Sympa::Archive;
use Conf;
use Sympa::Constants;
use Log;
use Message;
use Sympa::Message;
use SDM;
use tools;
......@@ -59,7 +59,7 @@ foreach my $msg_file (sort grep(!/^\./, readdir SPOOL)) {
);
next unless $metadata;
my $message =
Message->new_from_file($modspool . '/' . $msg_file, %$metadata);
Sympa::Message->new_from_file($modspool . '/' . $msg_file, %$metadata);
next unless $message;
my $list = $message->{'list'};
......
......@@ -30,7 +30,7 @@ use Getopt::Long;
use Conf;
use Sympa::Constants;
use List;
use Sympa::List;
use SDM;
my $sympa_conf_file = Sympa::Constants::CONFIG;
......@@ -73,7 +73,7 @@ if ( ($main::options{'help'} ne '')
} else {
if ($listname) {
my $self = List->new($listname, $robot);
my $self = Sympa::List->new($listname, $robot);
$cert = $self->{'dir'} . '/cert.pem';
$privatekey = $self->{'dir'} . '/private_key';
unless (-d $self->{'dir'}) {
......
......@@ -30,7 +30,7 @@ use warnings;
use Conf;
use Sympa::Constants;
use Sympa::Language;
use List;
use Sympa::List;
use Log;
use SDM;
use Sympa::Template::Compat;
......@@ -53,7 +53,7 @@ unless (Conf::load()) {
}
if ($Conf::Conf{'db_name'} and $Conf::Conf{'db_type'}) {
unless ($List::use_db = SDM::probe_db()) {
unless ($Sympa::List::use_db = SDM::probe_db()) {
die('Database %s defined in sympa.conf has not the right structure or is unreachable. If you don\'t use any database, comment db_xxx parameters in sympa.conf',
$Conf::Conf{'db_name'}
);
......@@ -126,7 +126,7 @@ foreach my $vr (keys %{$Conf::Conf{'robots'}}) {
}
## Search in V. Robot Lists
my $listOfLists = List::get_lists($vr);
my $listOfLists = Sympa::List::get_lists($vr);
foreach my $list (@$listOfLists) {
push @directories, $list->{'dir'};
......
......@@ -28,19 +28,14 @@ use strict;
use warnings;
use Getopt::Long;
use SOAP::Lite;
# Use this line for more debug facility
#use SOAP::Lite +trace;
use SOAP::Transport::HTTP;
## Defines SOAP::Transport::HTTP::FCGI::Sympa with a modified handle()
use SympaTransport;
## Sympa API
use Conf;
use List;
use Sympa::List;
use Log;
use mail;
use sympasoap;
use Sympa::Mail;
use Sympa::SOAP;
use Sympa::SOAP::Transport;
my $birthday = time;
......@@ -71,22 +66,19 @@ unless (SDM::check_db_connect()) {
## The process should not fork for sending mail
## Messages will be spooled instead
mail::set_send_spool($Conf::Conf{'queue'});
Sympa::Mail::set_send_spool($Conf::Conf{'queue'});
## Loading all Lists at startup, in order to increase execution speed
my $all_lists = List::get_lists('*');
foreach my $list (@$all_lists) {
## Nothing to do here
}
my $all_lists = Sympa::List::get_lists('*');
##############################################################################
# Soap part
##############################################################################
my $server = SOAP::Transport::HTTP::FCGI::Sympa->new();
my $server = Sympa::SOAP::Transport->new();
#$server->dispatch_with({'urn:Sympa' => 'sympasoap'});
$server->dispatch_to('--modulesdir--', 'sympasoap');
#$server->dispatch_with({'urn:Sympa' => 'Sympa::SOAP'});
$server->dispatch_to('--modulesdir--', 'Sympa::SOAP');
$server->handle($birthday);
This diff is collapsed.
......@@ -31,7 +31,7 @@ use Time::Local;
use Log;
use Conf;
use SympaSession;
use Sympa::Session;
use SDM;
# this structure is used to define which session attributes are stored in a dedicated database col where others are compiled in col 'data_session'
......@@ -80,7 +80,7 @@ sub load {
unless ($challenge_id) {
Log::do_log('err',
'Internal error, SympaSession::load called with undef id_challenge'
'Internal error. undefined id_challenge'
);
return undef;
}
......
......@@ -33,8 +33,8 @@ use Storable;
use Sympa::ConfDef;
use Sympa::Constants;
use Sympa::Language;
use List;
use Log;
use Sympa::Robot;
use SDM;
use tools;
......@@ -756,7 +756,7 @@ sub checkfiles {
if (defined $Conf{'cafile'} && $Conf{'cafile'}) {
unless (-f $Conf{'cafile'} && -r $Conf{'cafile'}) {
Log::do_log('err', 'Cannot access cafile %s', $Conf{'cafile'});
List::send_notify_to_listmaster('cannot_access_cafile',
Sympa::Robot::send_notify_to_listmaster('cannot_access_cafile',
$Conf{'domain'}, [$Conf{'cafile'}]);
$config_err++;
}
......@@ -765,7 +765,7 @@ sub checkfiles {
if (defined $Conf{'capath'} && $Conf{'capath'}) {
unless (-d $Conf{'capath'} && -x $Conf{'capath'}) {
Log::do_log('err', 'Cannot access capath %s', $Conf{'capath'});
List::send_notify_to_listmaster('cannot_access_capath',
Sympa::Robot::send_notify_to_listmaster('cannot_access_capath',
$Conf{'domain'}, [$Conf{'capath'}]);
$config_err++;
}
......@@ -778,7 +778,7 @@ sub checkfiles {
'Error in config: queuebounce and bounce_path parameters pointing to the same directory (%s)',
$Conf{'queuebounce'}
);
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'queuebounce_and_bounce_path_are_the_same',
$Conf{'domain'}, [$Conf{'queuebounce'}]);
$config_err++;
......@@ -792,7 +792,7 @@ sub checkfiles {
'Error in config: queue and queueautomatic parameters pointing to the same directory (%s)',
$Conf{'queue'}
);
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'queue_and_queueautomatic_are_the_same',
$Conf{'domain'}, [$Conf{'queue'}]);
$config_err++;
......@@ -862,7 +862,7 @@ sub checkfiles {
## Create directory if required
unless (-d $dir) {
unless (tools::mkdir_all($dir, 0755)) {
List::send_notify_to_listmaster('cannot_mkdir', $robot,
Sympa::Robot::send_notify_to_listmaster('cannot_mkdir', $robot,
["Could not create directory $dir: $!"]);
Log::do_log('err', 'Failed to create directory %s', $dir);
return undef;
......@@ -888,7 +888,7 @@ sub checkfiles {
rename $dir . '/' . $css, $dir . '/' . $css . '.' . time;
unless (open(CSS, ">$dir/$css")) {
List::send_notify_to_listmaster('cannot_open_file',
Sympa::Robot::send_notify_to_listmaster('cannot_open_file',
$robot, ["Could not open file $dir/$css: $!"]);
Log::do_log(
'err',
......@@ -905,7 +905,7 @@ sub checkfiles {
) {
my $error = tt2::get_error();
$param->{'tt2_error'} = $error;
List::send_notify_to_listmaster('web_tt2_error', $robot,
Sympa::Robot::send_notify_to_listmaster('web_tt2_error', $robot,
[$error]);
Log::do_log('err', 'Error while installing %s/%s',
$dir, $css);
......@@ -922,7 +922,7 @@ sub checkfiles {
}
if ($css_updated) {
## Notify main listmaster
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'css_updated',
$Conf{'domain'},
[ "Static CSS files have been updated ; check log file for details"
......@@ -2187,7 +2187,7 @@ sub _load_single_robot_config {
$config_file);
unless (-r $config_file) {
Log::do_log('err', 'No read access on %s', $config_file);
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'cannot_access_robot_conf',
$Conf{'domain'},
[ "No read access on $config_file. you should change privileges on this file to activate this virtual host. "
......
......@@ -31,7 +31,7 @@ use Scalar::Util;
use Sys::Syslog qw();
use Conf;
use List;
use Sympa::Robot;
use SDM;
use tools;
......@@ -69,7 +69,7 @@ sub fatal_err {
if ($@ && ($warning_date < time - $warning_timeout)) {
$warning_date = time + $warning_timeout;
unless (
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'logs_failed', $Conf::Conf{'domain'}, [$@]
)
) {
......@@ -81,7 +81,7 @@ sub fatal_err {
my $full_msg = sprintf $m, @_;
## Notify listmaster
List::send_notify_to_listmaster('sympa_died', $Conf::Conf{'domain'},
Sympa::Robot::send_notify_to_listmaster('sympa_died', $Conf::Conf{'domain'},
[$full_msg]);
printf STDERR "$m\n", @_;
......@@ -203,7 +203,7 @@ sub do_log {
};
if ($@ and $warning_date < time - $warning_timeout) {
$warning_date = time + $warning_timeout;
List::send_notify_to_listmaster('logs_failed', $Conf::Conf{'domain'},
Sympa::Robot::send_notify_to_listmaster('logs_failed', $Conf::Conf{'domain'},
[$@]);
}
}
......@@ -236,7 +236,7 @@ sub do_connect {
if ($@ && ($warning_date < time - $warning_timeout)) {
$warning_date = time + $warning_timeout;
unless (
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'logs_failed', $Conf::Conf{'domain'}, [$@]
)
) {
......@@ -357,7 +357,7 @@ sub db_stat_log {
my $id = $date . $random;
my $read = 0;
if (ref $list eq 'List') {
if (ref $list eq 'Sympa::List') {
$list = $list->{'name'};
} elsif ($list and $list =~ /(.+)\@(.+)/) {
#remove the robot name of the list name
......
......@@ -47,34 +47,33 @@ nobase_modules_DATA = \
Sympa/Language.pm \
Sympa/LDAP.pm \
Sympa/LDAPSource.pm \
List.pm \
Sympa/List.pm \
Sympa/ListDef.pm \
Sympa/LockedFile.pm \
Log.pm \
Sympa/ModDef.pm \
mail.pm \
Marc.pm \
Marc/Search.pm \
Message.pm \
PlainDigest.pm \
Sympa/Mail.pm \
Sympa/Marc.pm \
Sympa/Marc/Search.pm \
Sympa/Message.pm \
Sympa/PlainDigest.pm \
Sympa/Regexps.pm \
report.pm \
Robot.pm \
Scenario.pm \
Sympa/Report.pm \
Sympa/Robot.pm \
Sympa/Scenario.pm \
SDM.pm \
SharedDocument.pm \
SQLSource.pm \
SympaSession.pm \
sympasoap.pm \
SympaTransport.pm \
Task.pm \
Sympa/SharedDocument.pm \
Sympa/SQLSource.pm \
Sympa/Session.pm \
Sympa/SOAP.pm \
Sympa/SOAP/Transport.pm \
Sympa/Task.pm \
Sympa/Template/Compat.pm \
tools.pm \
tracking.pm \
Sympa/Tracking.pm \
tt2.pm \
Upgrade.pm \
Sympa/Upgrade.pm \
Sympa/User.pm \
WebAgent.pm \
wwslib.pm
man3dir = $(mandir)/man3
......
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# 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 GIP RENATER
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
## This package handles Sympa virtual robots
## It should :
## * provide access to global conf parameters,
## * deliver the list of lists
## * determine the current robot, given a host
package Robot;
use Conf;
## Constructor of a Robot instance
sub new {
my ($pkg, $name) = @_;
my $robot = {'name' => $name};
Log::do_log('debug2', '');
unless (defined $name && $Conf::Conf{'robots'}{$name}) {
Log::do_log('err', 'Unknown robot "%s"', $name);
return undef;
}
## The default robot
if ($name eq $Conf::Conf{'domain'}) {
$robot->{'home'} = $Conf::Conf{'home'};
} else {
$robot->{'home'} = $Conf::Conf{'home'} . '/' . $name;
unless (-d $robot->{'home'}) {
Log::do_log('err', 'Missing directory "%s" for robot "%s"',
$robot->{'home'}, $name);
return undef;
}
}
## Initialize internal list cache
undef %list_cache;
# create a new Robot object
bless $robot, $pkg;
return $robot;
}
## load all lists belonging to this robot
sub get_lists {
my $self = shift;
return List::get_lists($self->{'name'});
}
1;
......@@ -31,8 +31,9 @@ use Conf;
use Sympa::Constants;
use Sympa::DatabaseDescription;
use Log;
use List;
use SQLSource;
#use Sympa::List;
#use Sympa::Robot;
use Sympa::SQLSource;
use tools;
# db structure description has moved in Sympa/Constant.pm
......@@ -148,12 +149,12 @@ sub connect_sympa_database {
($option ne 'just_try' && !$ENV{'GATEWAY_INTERFACE'}),
'warn' => 1,
};
unless ($db_source = SQLSource->new($db_conf)) {
Log::do_log('err', 'Unable to create SQLSource object');
unless ($db_source = Sympa::SQLSource->new($db_conf)) {
Log::do_log('err', 'Unable to create Sympa::SQLSource object');
return undef;
}
## Used to check that connecting to the Sympa database works and the
## SQLSource object is created.
## Sympa::SQLSource object is created.
$use_db = 1;
# Just in case, we connect to the database here. Probably not necessary.
......@@ -330,10 +331,10 @@ sub probe_db {
}
## Used by List subroutines to check that the DB is available
$List::use_db = 1;
$Sympa::List::use_db = 1;
## Notify listmaster
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'db_struct_updated',
Conf::get_robot_conf('*', 'domain'),
{'report' => \@report}
......
......@@ -45,11 +45,12 @@ use IO::Scalar;
use Conf;
use Sympa::Constants;
use Sympa::Language;
use List;
use Sympa::List;
use Sympa::LockedFile;
use Log;
use Sympa::Regexps;
use Scenario;
use Sympa::Robot;
use Sympa::Scenario;
use SDM;
use tools;
use tt2;
......@@ -125,11 +126,11 @@ Creates a list. Used by the create_list() sub in sympa.pl and the do_create_list
=item * Conf::get_robot_conf
=item * List::create_shared
=item * Sympa::List::create_shared
=item * List::has_include_data_sources
=item * Sympa::List::has_include_data_sources
=item * List::sync_include
=item * Sympa::List::sync_include
=item * tools::search_fullpath
......@@ -233,7 +234,7 @@ sub create_list_old {
}
## Check this listname doesn't exist already.
if ($res || List->new($param->{'listname'}, $robot, {'just_try' => 1})) {
if ($res || Sympa::List->new($param->{'listname'}, $robot, {'just_try' => 1})) {
Log::do_log('err',
'Could not create already existing list %s on %s for',
$param->{'listname'}, $robot);
......@@ -332,7 +333,7 @@ sub create_list_old {
## Create list object
my $list;
unless ($list = List->new($param->{'listname'}, $robot)) {
unless ($list = Sympa::List->new($param->{'listname'}, $robot)) {
Log::do_log('err', 'Unable to create list %s', $param->{'listname'});
return undef;
}
......@@ -574,7 +575,7 @@ sub create_list {
## Create list object
my $list;
unless ($list = List->new($param->{'listname'}, $robot)) {
unless ($list = Sympa::List->new($param->{'listname'}, $robot)) {
Log::do_log('err', 'Unable to create list %s', $param->{'listname'});
return undef;
}
......@@ -681,7 +682,7 @@ sub update_list {
$lock_fh->close;
## Create list object
unless ($list = List->new($param->{'listname'}, $robot)) {
unless ($list = Sympa::List->new($param->{'listname'}, $robot)) {
Log::do_log('err', 'Unable to create list %s', $param->{'listname'});
return undef;
}
......@@ -784,7 +785,7 @@ sub rename_list {
## Evaluate authorization scenario unless run as listmaster (sympa.pl)
my ($result, $r_action, $reason);
unless ($param{'options'}{'skip_authz'}) {
$result = Scenario::request_action(
$result = Sympa::Scenario::request_action(
$param{'new_robot'},
'create_list',
$param{'auth_method'},
......@@ -816,7 +817,7 @@ sub rename_list {
if ($res
|| ($list->{'name'} ne $param{'new_listname'})
&& ## Do not test if listname did not change
( List->new(
( Sympa::List->new(
$param{'new_listname'}, $param{'new_robot'},
{'just_try' => 1}
)
......@@ -886,7 +887,7 @@ sub rename_list {
# set list status to pending if creation list is moderated
if ($r_action =~ /listmaster/) {
$list->{'admin'}{'status'} = 'pending';
List::send_notify_to_listmaster(
Sympa::Robot::send_notify_to_listmaster(
'request_list_renaming',
$list->{'domain'},
{ 'list' => $list,
......@@ -902,7 +903,7 @@ sub rename_list {
## Save config file for the new() later to reload it
$list->save_config($param{'user_email'});
## This code should be in List::rename()
## This code should be in Sympa::List::rename()
unless ($param{'mode'} eq 'copy') {
unless (File::Copy::move($list->{'dir'}, $new_dir)) {
Log::do_log('err', 'Unable to rename %s to %s: %m',
......@@ -941,7 +942,7 @@ sub rename_list {
}
# if subscribtion are stored in database rewrite the database
List::rename_list_db($list, $param{'new_listname'},
Sympa::List::rename_list_db($list, $param{'new_listname'},
$param{'new_robot'});
}
## Move stats
......@@ -988,7 +989,7 @@ sub rename_list {
$param{'listname'} = $param{'new_listname'};
unless (
$list = List->new(
$list = Sympa::List->new(
$param{'new_listname'}, $param{'new_robot'},
{'reload_config' => 1}
)
......@@ -1144,7 +1145,7 @@ sub clone_list_as_empty {
my $email = shift;
my $list;
unless ($list = List->new($source_list_name, $source_robot)) {
unless ($list = Sympa::List->new($source_list_name, $source_robot)) {
Log::do_log('err', 'New list failed %s %s',
$source_list_name, $source_robot);
return undef;
......@@ -1226,7 +1227,7 @@ sub clone_list_as_empty {
my $new_list;
# now switch List object to new list, update some values
unless ($new_list =
List->new($new_listname, $new_robot, {'reload_config' => 1})) {
Sympa::List->new($new_listname, $new_robot, {'reload_config' => 1})) {
Log::do_log('info',
"Admin::clone_list_as_empty : unable to load $new_listname while renamming"
);
......@@ -1580,7 +1581,7 @@ sub check_topics {
my ($top, $subtop) = split /\//, $topic;
my %topics;
unless (%topics = List::load_topics($robot)) {
unless (%topics = Sympa::Robot::load_topics($robot)) {
Log::do_log('err', 'Unable to load list of topics');
}
......@@ -1608,17 +1609,17 @@ sub check_topics {
sub change_user_email {
my %in = @_;
my $robot_id = $in{'robot'};
my @failed_for;
unless ($in{'current_email'} && $in{'new_email'} && $in{'robot'}) {
Log::do_log('err', 'Missing incoming parameter');
return undef;
unless ($in{'current_email'} and $in{'new_email'} and $in{'robot'}) {
die 'Missing incoming parameter';
}
## Change email as list MEMBER
foreach my $list (
List::get_which($in{'current_email'}, $in{'robot'}, 'member')) {
Sympa::List::get_which($in{'current_email'}, $robot_id, 'member')) {
my $l = $list->{'name'};
my $user_entry = $list->get_list_member($in{'current_email'});
......@@ -1632,9 +1633,9 @@ sub change_user_email {
foreach my $datasource_id (split(/,/, $user_entry->{'id'})) {