From c9b4e6bc629fb185b380cda69bca5d3460bc58e0 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Mon, 4 Sep 2017 08:29:10 +0200 Subject: [PATCH] =?utf8?q?Filemanagement:=20Zentralisierte=20Pr=C3=BCfung?= =?utf8?q?=20ob=20bei=20Drucken=20im=20DMS=20gespeichert=20wird?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Prüfung aller Mandanteneinstellung vor Speicherung im DMS, fixt #286 --- SL/Form.pm | 6 +++--- SL/Helper/File.pm | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index fa2a83542..4c8cebfb1 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1067,14 +1067,14 @@ sub parse_template { # therefore copy to webdav, even if we do not have the webdav feature enabled (just archive) my $copy_to_webdav = $::instance_conf->get_webdav_documents && !$self->{preview} && $self->{tmpdir} && $self->{tmpfile} && $self->{type}; - if ( $ext_for_format eq 'pdf' && $::instance_conf->get_doc_storage ) { + if ( $ext_for_format eq 'pdf' && $self->doc_storage_enabled ) { $self->append_general_pdf_attachments(filepath => $self->{tmpdir}."/".$self->{tmpfile}, type => $self->{type}); } if ($self->{media} eq 'file') { copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file; Common::copy_file_to_webdav_folder($self) if $copy_to_webdav; - if (!$self->{preview} && $::instance_conf->get_doc_storage) + if (!$self->{preview} && $self->doc_storage_enabled) { $self->{attachment_filename} ||= $self->generate_attachment_filename; $self->store_pdf($self); @@ -1089,7 +1089,7 @@ sub parse_template { Common::copy_file_to_webdav_folder($self) if $copy_to_webdav; - if ( !$self->{preview} && $ext_for_format eq 'pdf' && $::instance_conf->get_doc_storage) { + if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->doc_storage_enabled) { $self->{attachment_filename} ||= $self->generate_attachment_filename; my $file_obj = $self->store_pdf($self); $self->{print_file_id} = $file_obj->id if $file_obj; diff --git a/SL/Helper/File.pm b/SL/Helper/File.pm index d59fb56ac..b90948f32 100644 --- a/SL/Helper/File.pm +++ b/SL/Helper/File.pm @@ -3,13 +3,20 @@ package SL::Helper::File; use strict; use Exporter 'import'; -our @EXPORT_OK = qw(store_pdf append_general_pdf_attachments); +our @EXPORT_OK = qw(store_pdf append_general_pdf_attachments doc_storage_enabled); our %EXPORT_TAGS = (all => \@EXPORT_OK,); use SL::File; +sub doc_storage_enabled { + return 0 unless $::instance_conf->get_doc_storage; + return 1 if $::instance_conf->get_doc_storage_for_documents eq 'Filesystem' && $::instance_conf->get_doc_files; + return 1 if $::instance_conf->get_doc_storage_for_documents eq 'Webdav' && $::instance_conf->get_doc_webdav; + return 0; +} + sub store_pdf { my ($self, $form) = @_; - return unless $::instance_conf->get_doc_storage; + return unless $self->doc_storage_enabled; my $type = $form->{type}; $type = $form->{formname} if $form->{formname} && !$form->{type}; $type = $form->{attachment_type} if $form->{attachment_type}; @@ -72,7 +79,6 @@ __END__ SL::Helper::File - Helper for $::Form to store generated PDF-Documents - =head1 SYNOPSIS # This Helper is used by SL::Form to store new generated PDF-Files and append general attachments to this documents. -- 2.20.1