Commit 78125669 authored by sikeda's avatar sikeda
Browse files

[-dev] Constructors of Sympa::Tracking and Sympa::Archive may take argument as plain hash pairs.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12575 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent d4a0eb2c
......@@ -9722,7 +9722,7 @@ sub do_arc {
unless ($session->{'archive_sniffer'} eq 'false');
}
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
# Calendar
my @arcs = $archive->get_archives;
unless (@arcs) {
......@@ -9888,8 +9888,8 @@ sub do_latest_arc {
$nb_arc = $NB_ARC_MAX;
}
 
my $archive = Sympa::Archive->new($list);
my @arcs = reverse $archive->get_archives;
my $archive = Sympa::Archive->new(context => $list);
my @arcs = reverse $archive->get_archives;
my $stop_search;
my @archives;
 
......@@ -10051,7 +10051,7 @@ sub do_remove_arc {
}
 
my $msg_string = "\n\n";
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
foreach my $msgid (@msgids) {
chomp $msgid;
$msg_string .= sprintf "remove_arc %s %s-%s %s\n", $list->{'name'},
......@@ -10127,7 +10127,7 @@ sub do_send_me {
return undef;
}
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
my ($message, $handle);
if ($archive->select_archive("$in{'yyyy'}-$in{'month'}")) {
($message, $handle) = $archive->fetch(message_id => $in{'msgid'});
......@@ -10137,7 +10137,7 @@ sub do_send_me {
$message->smime_decrypt;
 
# Add or remove several header fields.
Sympa::Spindle::TransformOutgoing->post_archive($message); #FIXME
Sympa::Spindle::TransformOutgoing->post_archive($message); #FIXME
 
# Add footer/header.
$message->decorate;
......@@ -10232,7 +10232,7 @@ sub do_view_source {
return undef;
}
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
my ($message, $handle);
if ($archive->select_archive("$in{'yyyy'}-$in{'month'}")) {
($message, $handle) = $archive->fetch(message_id => $in{'msgid'});
......@@ -10365,7 +10365,7 @@ sub do_arcsearch_form {
unless (
defined check_authz('do_arcsearch_form', 'archive.web_access'));
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
$param->{'yyyymm'} = [reverse $archive->get_archives];
$param->{'key_word'} = $in{'key_word'};
$param->{'archive_name'} = $in{'archive_name'};
......@@ -10381,8 +10381,8 @@ sub do_arcsearch {
return undef
unless defined check_authz('do_arcsearch', 'archive.web_access');
 
my $search = Sympa::Marc::Search->new;
my $archive = Sympa::Archive->new($list);
my $search = Sympa::Marc::Search->new;
my $archive = Sympa::Archive->new(context => $list);
$search->search_base($archive->{base_directory});
$search->base_href(Conf::get_robot_conf($robot, 'wwsympa_url') . '/arc/'
. $param->{'list'});
......@@ -10520,8 +10520,8 @@ sub do_arcsearch_id {
return undef
unless defined check_authz('do_arcsearch_id', 'archive.web_access');
 
my $search = Sympa::Marc::Search->new;
my $archive = Sympa::Archive->new($list);
my $search = Sympa::Marc::Search->new;
my $archive = Sympa::Archive->new(context => $list);
$search->search_base($archive->{base_directory});
$search->base_href(Conf::get_robot_conf($robot, 'wwsympa_url') . '/arc/'
. $param->{'list'});
......@@ -22878,7 +22878,7 @@ sub do_arc_manage {
return undef
unless defined check_authz('do_arc', 'archive.web_access');
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
$param->{'yyyymm'} = [reverse $archive->get_archives];
 
return 1;
......@@ -22919,7 +22919,7 @@ sub do_arc_download {
return 'arc_manage';
}
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
 
# For each selected month
foreach my $arc (split /\0/, $in{'directories'}) {
......@@ -23131,7 +23131,7 @@ sub do_arc_delete {
do_arc_download();
}
 
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
foreach my $arc (split /\0/, $in{'directories'}) {
unless ($archive->purge_archive($arc)) {
wwslog('info', 'Error while purging archive %s in %s',
......
......@@ -48,7 +48,14 @@ my $log = Sympa::Log->instance;
sub new {
my $class = shift;
my $list = shift;
my $list;
if (ref $_[0]) { # Compat., not recommended.
$list = shift;
} else {
my %options = @_;
$list = $options{context};
}
die 'Bug in logic. Ask developer' unless ref $list eq 'Sympa::List';
my $robot_id = $list->{'domain'};
......@@ -992,7 +999,7 @@ Sympa::Archive - Archives of Sympa
=head1 SYNOPSIS
use Sympa::Archive;
$archive = Sympa::Archive->new($list);
$archive = Sympa::Archive->new(context => $list);
@arcs = $archive->get_archives;
......@@ -1017,7 +1024,7 @@ L<Sympa::Archive> implements the interface to handle archives.
=over
=item new ( $list )
=item new ( context =E<gt> $list )
I<Constructor>.
Creates new instance of L<Sympa::Archive>.
......@@ -1026,7 +1033,7 @@ Parameter:
=over
=item $list
=item context =E<gt> $list
Context of object, a L<Sympa::List> instance.
......
......@@ -501,7 +501,7 @@ sub getfile {
return 'not_allowed';
}
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
my @msg_list;
unless ($archive->select_archive($arc)) {
Sympa::Report::reject_report_cmd('user', 'no_required_file', {},
......@@ -653,7 +653,7 @@ sub last {
}
my ($arc_message, $arc_handle);
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
foreach my $arc (reverse $archive->get_archives) {
next unless $archive->select_archive($arc);
($arc_message, $arc_handle) = $archive->next(reverse => 1);
......@@ -802,7 +802,7 @@ sub index {
my @arcs;
if ($list->is_archived) {
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
foreach my $arc ($archive->get_archives) {
my $info = $archive->select_archive($arc, info => 1);
next unless $info;
......
......@@ -9434,9 +9434,9 @@ sub purge {
if ($self->{'name'}) {
#FIXME: Lock directories to remove them safely.
my $archive = Sympa::Archive->new($self);
my $digest = Sympa::Spool::Digest->new(context => $self);
my $tracking = Sympa::Tracking->new($self);
my $archive = Sympa::Archive->new(context => $self);
my $digest = Sympa::Spool::Digest->new(context => $self);
my $tracking = Sympa::Tracking->new(context => $self);
my $error;
File::Path::remove_tree($archive->{base_directory},
{error => \$error});
......
......@@ -209,7 +209,7 @@ sub _twist {
'%s: DSN detected: dsn_status=%s; rcpt=%s; arrival_date=%s',
$message, $dsn_status, $who, $arrival_date);
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
if ($tracking->store(
$message, $who,
envid => $distribution_id,
......@@ -268,7 +268,7 @@ sub _twist {
$date
);
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
if ($tracking->store(
$message, $who,
envid => $distribution_id,
......@@ -551,7 +551,7 @@ sub _twist {
}
} elsif (%hash and $who) {
# VERP in use.
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
my ($status) = values %hash;
if ($tracking->store($message, $who, status => $status)) {
......@@ -571,7 +571,7 @@ sub _twist {
$numreported++;
}
} elsif (%hash) {
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
while (my ($rcpt, $status) = each %hash) {
if ($tracking->store($message, $rcpt, status => $status)) {
......
......@@ -214,7 +214,7 @@ sub _do_remove_arc {
my $msgid = shift;
my $sender = shift;
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
unless ($archive->select_archive($arc)) {
$log->syslog('err', 'No archive %s of %s', $arc, $archive);
return undef;
......@@ -275,7 +275,7 @@ sub _do_rebuildarc {
my $list = shift;
my $arc = shift;
my $archive = Sympa::Archive->new($list);
my $archive = Sympa::Archive->new(context => $list);
if ($arc and $arc ne '*') {
$log->syslog('notice', 'Rebuilding %s of %s', $arc, $archive);
......@@ -294,8 +294,8 @@ sub _mail2arc {
$log->syslog('debug2', '(%s)', @_);
my $message = shift;
my $list = $message->{context};
my $archive = Sympa::Archive->new($list);
my $list = $message->{context};
my $archive = Sympa::Archive->new(context => $list);
# chdir $arcpath;
......
......@@ -287,7 +287,7 @@ sub _send_msg {
$new_message->{shelved}{tracking} ||= 'verp';
if ($new_message->{shelved}{tracking} =~ /dsn|mdn/) {
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
$tracking->register($new_message, [@verp_selected_tabrcpt],
'reception_option' => $mode);
......@@ -347,7 +347,6 @@ sub _send_msg {
return $nbr_smtp;
}
# Distribute a message to a list, shelving encryption if needed.
#
# IN : -$message(+) : ref(Sympa::Message)
......
......@@ -40,7 +40,14 @@ my $log = Sympa::Log->instance;
sub new {
my $class = shift;
my $list = shift;
my $list;
if (ref $_[0]) { # Compat., not recommended.
$list = shift;
} else {
my %options = @_;
$list = $options{context};
}
die 'Bug in logic. Ask developer'
unless ref $list eq 'Sympa::List';
......@@ -596,7 +603,7 @@ each message.
=over
=item new ( $list )
=item new ( context =E<gt> $list )
I<Constructor>.
Creates new L<Sympa::Tracking> instance.
......@@ -605,7 +612,7 @@ Parameter:
=over
=item $list
=item context =E<gt> $list
L<Sympa::List> object.
......
......@@ -1477,7 +1477,7 @@ sub purge_tables {
return 1 if $end;
foreach my $list (@{$all_lists || []}) {
my $tracking = Sympa::Tracking->new($list);
my $tracking = Sympa::Tracking->new(context => $list);
$removed +=
$tracking->remove_message_by_period(
......
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