From 3a91ef77385d9302a4669502695ef17fdd99c285 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 20 Apr 2016 11:06:06 +0200 Subject: [PATCH] Brieffunktion: WebDAV-Verzeichnisinhalt anzeigen --- SL/Controller/Letter.pm | 23 ++++++++++++++++++++++- templates/webpages/letter/edit.html | 5 +++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/SL/Controller/Letter.pm b/SL/Controller/Letter.pm index 14922a77a..7905cb759 100644 --- a/SL/Controller/Letter.pm +++ b/SL/Controller/Letter.pm @@ -23,7 +23,7 @@ use SL::Webdav; use SL::Webdav::File; use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(letter all_employees models) ], + 'scalar --get_set_init' => [ qw(letter all_employees models webdav_objects) ], ); __PACKAGE__->run_before('check_auth_edit'); @@ -598,6 +598,27 @@ sub init_all_employees { SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); } +sub init_webdav_objects { + my ($self) = @_; + + return [] if !$self->letter || !$self->letter->letternumber || !$::instance_conf->get_webdav; + + my $webdav = SL::Webdav->new( + type => 'letter', + number => $self->letter->letternumber, + ); + + my $webdav_path = $webdav->webdav_path; + my @all_objects = $webdav->get_all_objects; + + return [ map { + +{ name => $_->filename, + type => t8('File'), + link => File::Spec->catdir($webdav_path, $_->filename), + } + } @all_objects ]; +} + sub check_auth_edit { $::auth->assert('sales_letter_edit'); } diff --git a/templates/webpages/letter/edit.html b/templates/webpages/letter/edit.html index de10fd425..239c84183 100644 --- a/templates/webpages/letter/edit.html +++ b/templates/webpages/letter/edit.html @@ -3,6 +3,7 @@ [%- USE L %] [%- USE P %] [%- USE LxERP %] +[%- SET WEBDAV = SELF.webdav_objects %]

[% title | html %]

@@ -16,6 +17,9 @@ @@ -136,6 +140,7 @@ + [% PROCESS 'webdav/_list.html' %]
[%- LxERP.t8("Loading...") %]
-- 2.20.1