Commit 4bca7ac9 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Inconsistent location of messge footer/header files #507

Fixes:

  - Message footer/header files of domain/site default are put in `mail_tt2` subdirectories while those of list config are not.
    Fixed by put all of them in consistent location without intermediate directories (See also Notes below).
  - Entries for header/footer files in `edit_list.conf` were ignored.

Changes:

  - File names themselves of header/footer were changed:
    `message_header`, `message_header.mime` etc.
    This is due to concideration about conflict between files and directories with domain names (See also Notes below).
  - Header/footer files with `.mime` extension:
    Previously, files with this extension were always preferred, then files without extension were used.  This behavior has not been documented.
    Now files with extension will be searched only in case `footer_type` is `mime`.  Files without extension will be searched in both cases.

Notes:

  - Files with older names/paths in list/domain/site config directories will be copied to new location during upgrading process.
  - Template files with old names in families (`message.header.tt2` etc.) will be used as before and will be copied to new location during instantiation. If files with new names (`message_header.tt2` etc.) will be preferred, if they will be added.

Known bug:

  - There are no web UI to edit global footer (`message_global_footer`).
parent 4a844b49
......@@ -6104,29 +6104,6 @@ sub do_setpasswd {
sub do_admin {
wwslog('info', '');
 
## Messages edition
#FIXME: No longer used: Kept for backward compatibility.
foreach my $f (
'info', 'homepage',
'welcome.tt2', 'bye.tt2',
'removed.tt2', 'message.footer',
'message.header', 'remind.tt2',
'invite.tt2', 'reject.tt2'
) {
my ($role, $right) =
$list->may_edit($f, $param->{'user'}{'email'}, file => 1);
next unless $right eq 'write';
if ($Sympa::WWW::Tools::filenames{$f}{'gettext_id'}) {
$param->{'files'}{$f}{'complete'} =
$language->gettext(
$Sympa::WWW::Tools::filenames{$f}{'gettext_id'});
} else {
$param->{'files'}{$f}{'complete'} = $f;
}
$param->{'files'}{$f}{'selected'} = '';
}
$param->{'files'}{'info'}{'selected'} = 'selected="selected"';
return 1;
}
 
......@@ -6139,8 +6116,8 @@ sub do_serveradmin {
## Lists Default files
foreach my $f (
'welcome.tt2', 'bye.tt2',
'removed.tt2', 'message.footer',
'message.header', 'remind.tt2',
'removed.tt2', 'message_header',
'message_footer', 'remind.tt2',
'invite.tt2', 'reject.tt2',
'your_infected_msg.tt2'
) {
......@@ -8243,16 +8220,16 @@ sub do_editfile {
description_templates => ['info', 'homepage'],
message_templates => [
'welcome.tt2', 'bye.tt2',
'removed.tt2', 'message.footer',
'message.header', 'remind.tt2',
'removed.tt2', 'message_header',
'message_footer', 'remind.tt2',
'invite.tt2', 'reject.tt2',
'your_infected_msg.tt2'
],
all_templates => [
'info', 'homepage',
'welcome.tt2', 'bye.tt2',
'removed.tt2', 'message.footer',
'message.header', 'remind.tt2',
'removed.tt2', 'message_header',
'message_footer', 'remind.tt2',
'invite.tt2', 'reject.tt2',
'your_infected_msg.tt2'
]
......
......@@ -863,7 +863,7 @@ our @params = (
'file' => 'sympa.conf',
'split_char' => ',',
'default' =>
'message.footer,message.header,message.footer.mime,message.header.mime,info',
'message_header,message_header.mime,message_footer,message_footer.mime,info',
'vhost' => '1',
},
......
......@@ -4176,7 +4176,11 @@ sub may_edit {
## What privilege does he/she has?
my ($what, @order);
if ($parameter =~ /^(\w+)\.(\w+)$/ and $parameter !~ /\.tt2$/) {
if ( $parameter =~ /^(\w+)\.(\w+)$/
and $parameter !~ /\.tt2$/
and $parameter ne 'message_header.mime'
and $parameter ne 'message_footer.mime'
and $parameter ne 'message_global_footer.mime') {
my $main_parameter = $1;
@order = (
$edit_list_conf->{$parameter}{$role},
......
......@@ -1650,8 +1650,7 @@ sub _decorate_parts {
my $entity = shift;
my $list = shift;
my $type = $list->{'admin'}{'footer_type'};
my $listdir = $list->{'dir'};
my $type = $list->{'admin'}{'footer_type'};
my $eff_type = $entity->effective_type || 'text/plain';
## Signed or encrypted messages won't be modified.
......@@ -1659,61 +1658,24 @@ sub _decorate_parts {
return $entity;
}
my $header;
foreach my $file (
"$listdir/message.header",
"$listdir/message.header.mime",
$Conf::Conf{'etc'} . '/mail_tt2/message.header',
$Conf::Conf{'etc'} . '/mail_tt2/message.header.mime'
) {
if (-f $file) {
unless (-r $file) {
$log->syslog('notice', 'Cannot read %s', $file);
next;
}
$header = $file;
last;
}
}
my $footer;
foreach my $file (
"$listdir/message.footer",
"$listdir/message.footer.mime",
$Conf::Conf{'etc'} . '/mail_tt2/message.footer',
$Conf::Conf{'etc'} . '/mail_tt2/message.footer.mime'
) {
if (-f $file) {
unless (-r $file) {
$log->syslog('notice', 'Cannot read %s', $file);
next;
}
$footer = $file;
last;
}
}
my $global_footer;
foreach my $file (
$Conf::Conf{'etc'} . '/mail_tt2/message.global_footer',
$Conf::Conf{'etc'} . '/mail_tt2/message.global_footer.mime'
) {
if (-f $file) {
unless (-r $file) {
$log->syslog('notice', 'Cannot read %s', $file);
next;
}
$global_footer = $file;
last;
}
}
## No footer/header
unless (($header and -s $header)
or ($footer and -s $footer)
or ($global_footer and -s $global_footer)) {
return undef;
}
my $header =
($type eq 'mime')
&& Sympa::search_fullpath($list, 'message_header.mime')
|| Sympa::search_fullpath($list, 'message_header');
my $footer =
($type eq 'mime')
&& Sympa::search_fullpath($list, 'message_footer.mime')
|| Sympa::search_fullpath($list, 'message_footer');
my $global_footer =
($type eq 'mime')
&& Sympa::search_fullpath($list->{'domain'},
'message_global_footer.mime')
|| Sympa::search_fullpath($list->{'domain'}, 'message_global_footer');
# No footer/header.
return
unless $header and -s $header
or $footer and -s $footer
or $global_footer and -s $global_footer;
if ($type eq 'append') {
## append footer/header
......
......@@ -165,13 +165,23 @@ sub _twist {
## Create associated files if a template was given.
my @files_to_parse;
foreach my $file (split ',',
foreach my $file (split /\s*,\s*/,
Conf::get_robot_conf($robot_id, 'parsed_family_files')) {
$file =~ s{\s}{}g;
# Compat. <= 6.2.38: message.* were moved to message_*.
$file =~ s/\Amessage[.](header|footer)\b/message_$1/;
push @files_to_parse, $file;
}
for my $file (@files_to_parse) {
my $template_file = Sympa::search_fullpath($family, $file . ".tt2");
# Compat. <= 6.2.38: message.* were obsoleted by message_*.
my $file_obs;
if ($file =~ /\Amessage_(header|footer)\b(.*)\z/) {
$file_obs = "message.$1$2";
}
my $template_file = Sympa::search_fullpath($family, $file . '.tt2');
$template_file = Sympa::search_fullpath($family, $file_obs . '.tt2')
if not $template_file and $file_obs;
if (defined $template_file) {
my $file_content;
my $template =
......
......@@ -508,7 +508,7 @@ sub _copy {
}
}
# copy optional files
foreach my $file ('message.footer', 'message.header', 'info', 'homepage')
foreach my $file ('message_header', 'message_footer', 'info', 'homepage')
{
if (-f $current_list->{'dir'} . '/' . $file) {
unless (
......
......@@ -125,13 +125,23 @@ sub _twist {
## Create associated files if a template was given.
my @files_to_parse;
foreach my $file (split ',',
foreach my $file (split /\s*,\s*/,
Conf::get_robot_conf($robot_id, 'parsed_family_files')) {
$file =~ s{\s}{}g;
# Compat. <= 6.2.38: message.* were moved to message_*.
$file =~ s/\Amessage[.](header|footer)\b/message_$1/;
push @files_to_parse, $file;
}
for my $file (@files_to_parse) {
my $template_file = Sympa::search_fullpath($family, $file . ".tt2");
# Compat. <= 6.2.38: message.* were obsoleted by message_*.
my $file_obs;
if ($file =~ /\Amessage_(header|footer)\b(.*)\z/) {
$file_obs = "message.$1$2";
}
my $template_file = Sympa::search_fullpath($family, $file . '.tt2');
$template_file = Sympa::search_fullpath($family, $file_obs . '.tt2')
if not $template_file and $file_obs;
if (defined $template_file) {
my $file_content;
......
......@@ -1900,6 +1900,53 @@ sub upgrade {
}
}
if (lower_version($previous_version, '6.2.39b.1')) {
# The header/footer files were renamed.
# Site-level files were moved.
my %file_map = (
'message.header' => 'message_header',
'message.footer' => 'message_footer',
'message.global_footer' => 'message_global_footer'
);
my $all_lists = Sympa::List::get_lists('*');
foreach my $list (@{$all_lists || []}) {
my $dir = $list->{'dir'};
foreach my $file (keys %file_map) {
next if $file eq 'message.global_footer';
my $new_file = $file_map{$file};
if (-e $dir . '/' . $file and !-e $dir . '/' . $new_file) {
File::Copy::copy($dir . '/' . $file,
$dir . '/' . $new_file);
}
if (-e $dir . '/' . $file . '.mime'
and !-e $dir . '/' . $new_file . '.mime') {
File::Copy::copy(
$dir . '/' . $file . '.mime',
$dir . '/' . $new_file . '.mime'
);
}
}
}
my $dir = $Conf::Conf{'etc'};
foreach my $file (keys %file_map) {
my $new_file = $file_map{$file};
if (-e $dir . '/mail_tt2/' . $file) {
File::Copy::copy($dir . '/mail_tt2/' . $file,
$dir . '/' . $new_file);
}
if (-e $dir . '/mail_tt2/' . $file . '.mime') {
File::Copy::copy(
$dir . '/mail_tt2/' . $file . '.mime',
$dir . '/' . $new_file . '.mime'
);
}
}
}
return 1;
}
......
......@@ -61,13 +61,13 @@ our %cookie_period = (
43200 => {'gettext_id' => "30 days"}
);
## Filenames with corresponding entry in NLS set 15
# File names with corresponding entry in NLS set
our %filenames = (
'welcome.tt2' => {'gettext_id' => "welcome message"},
'bye.tt2' => {'gettext_id' => "unsubscribe message"},
'removed.tt2' => {'gettext_id' => "deletion message"},
'message.footer' => {'gettext_id' => "message footer"},
'message.header' => {'gettext_id' => "message header"},
'message_header' => {'gettext_id' => "message header"},
'message_footer' => {'gettext_id' => "message footer"},
'remind.tt2' => {'gettext_id' => "remind message"},
'reject.tt2' => {'gettext_id' => "moderator rejection message"},
'invite.tt2' => {'gettext_id' => "subscribing invitation message"},
......
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