Commit 16150cbe authored by sympa-authors's avatar sympa-authors
Browse files

Fix: could not edit message.header and message.footer from the admin web interface

The tools::get_filename() sub did not return the right structure ; it should return an empty array if expected


git-svn-id: https://subversion.renater.fr/sympa/trunk@3948 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 65fe6b4d
......@@ -7642,8 +7642,10 @@ sub search{
my @files = &tools::get_filename('etc',{'order'=>'all'},"search_filters/$filter_file", $robot, $list);
## Raise an error except for blacklist.txt
unless ($filter_file eq 'blacklist.txt') {
unless (@files) {
unless (@files) {
if ($filter_file eq 'blacklist.txt') {
return -1;
}else {
&do_log('err', 'Could not find search filter %s', $filter_file);
return undef;
}
......@@ -7653,7 +7655,7 @@ sub search{
foreach my $file (@files) {
&do_log('debug3', 'List::search: found file %s', $file);
unless (open FILE, $file) {
&do_log('err', 'Could not openfile %s', $file);
&do_log('err', 'Could not open file %s', $file);
return undef;
}
while (<FILE>) {
......@@ -12478,4 +12480,4 @@ sub get_list_id {
#################################################################
## Packages must return true.
1;
\ No newline at end of file
1;
......@@ -1675,6 +1675,7 @@ sub duration_conv {
}
## Look for a file in the list > robot > server > default locations
## Possible values for $options : order=all
sub get_filename {
my ($type, $options, $name, $robot, $object) = @_;
my $list;
......@@ -1738,14 +1739,17 @@ sub get_filename {
if (-r $f) {
if ($options->{'order'} eq 'all') {
push @result, $f;
}else {
return $f;
}
return $f;
}
}
return (@result) ;
if ($options->{'order'} eq 'all') {
return @result ;
}
}
&do_log('notice','tools::get_filename: Cannot find %s in %s', $name, join(',',@try));
#&do_log('notice','tools::get_filename: Cannot find %s in %s', $name, join(',',@try));
return undef;
}
####################################################
......
......@@ -6031,21 +6031,26 @@ sub do_viewmod {
## Look for the template
$param->{'filepath'} = &tools::get_filename('etc',{},$subdir.$file,$robot, $list);
 
## open file and provide filecontent to the parser
## It allows to us the correct file encoding
unless (open FILE, "<:encoding($Conf{'filesystem_encoding'})", $param->{'filepath'}) {
&report::reject_report_web('intern','cannot_open_file',{'file' => $param->{'filepath'}},$param->{'action'},$list,$param->{'user'}{'email'},$robot);
&wwslog('err','do_editfile: failed to open file %s: %s', $param->{'filepath'},$!);
&web_db_log({'parameters' => $in{'file'},
'status' => 'error',
'error_type' => 'internal'});
return undef;
}
while (<FILE>) {
$param->{'filecontent'} .= $_;
## There might be no matching file if default template not provided with Sympa
if (defined $param->{'filepath'}) {
## open file and provide filecontent to the parser
## It allows to us the correct file encoding
unless (open FILE, "<:encoding($Conf{'filesystem_encoding'})", $param->{'filepath'}) {
&report::reject_report_web('intern','cannot_open_file',{'file' => $param->{'filepath'}},$param->{'action'},$list,$param->{'user'}{'email'},$robot);
&wwslog('err','do_editfile: failed to open file %s: %s', $param->{'filepath'},$!);
&web_db_log({'parameters' => $in{'file'},
'status' => 'error',
'error_type' => 'internal'});
return undef;
}
while (<FILE>) {
$param->{'filecontent'} .= $_;
}
close FILE;
}else {
$param->{'filepath'} = $list->{'dir'}.'/'.$subdir.$file;
}
close FILE;
## Default for 'homepage' is 'info'
if (($in{'file'} eq 'homepage') &&
......@@ -6075,7 +6080,7 @@ sub do_viewmod {
}
}
 
if ($param->{'filepath'} && (! -r $param->{'filepath'})) {
if (-f $param->{'filepath'} && (! -r $param->{'filepath'})) {
&report::reject_report_web('intern','cannot_read',{'filepath' => $param->{'filepath'}},$param->{'action'},'',$param->{'user'}{'email'},$robot);
&wwslog('err','do_editfile: cannot read %s', $param->{'filepath'});
&web_db_log({'parameters' => $in{'file'},
......
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