X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/480c67096c7aab3ccfe6b55e8d981975c7f08578..ab96e204a2beec2302b1850df50f45a6e67a13c4:/SL/Common.pm diff --git a/SL/Common.pm b/SL/Common.pm index fdf2b2808..5ac63c695 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -260,7 +260,7 @@ sub webdav_folder { my ($path, $number); - $form->{WEBDAV} = {}; + $form->{WEBDAV} = []; if ($form->{type} eq "sales_quotation") { ($path, $number) = ("angebote", $form->{quonumber}); @@ -280,6 +280,8 @@ sub webdav_folder { return $main::lxdebug->leave_sub() unless ($path && $number); + $number =~ s|[/\\]|_|g; + $path = "webdav/${path}/${number}"; if (!-d $path) { @@ -288,13 +290,28 @@ sub webdav_folder { } else { my $base_path = substr($ENV{'SCRIPT_NAME'}, 1); $base_path =~ s|[^/]+$||; + $base_path =~ s|/$||; + + if (opendir $dir, $path) { + foreach my $file (sort { lc $a cmp lc $b } readdir $dir) { + next if (($file eq '.') || ($file eq '..')); + + my $fname = $file; + $fname =~ s|.*/||; + + my $is_directory = -d "$path/$file"; + + $file = join('/', map { $form->escape($_) } grep { $_ } split m|/+|, "$path/$file"); + $file .= '/' if ($is_directory); + + push @{ $form->{WEBDAV} }, { + 'name' => $fname, + 'link' => ($ENV{"HTTPS"} ? "https://" : "http://") . $ENV{'SERVER_NAME'} . "/$base_path/$file", + 'type' => $is_directory ? $main::locale->text('Directory') : $main::locale->text('File'), + }; + } - foreach my $file (<$path/*>) { - my $fname = $file; - $fname =~ s|.*/||; - $form->{WEBDAV}{$fname} = - ($ENV{"HTTPS"} ? "https://" : "http://") . - $ENV{'SERVER_NAME'} . "/" . $base_path . $file; + closedir $dir; } }