From: Sven Schöling Date: Mon, 19 Dec 2011 17:42:06 +0000 (+0100) Subject: 3-arg open: Mode für zu öffnende Pipes separat sichern X-Git-Tag: release-2.7.0beta1~120 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6ff1674fc7d8e48723efa5a8152ac468c5d4ea58;p=kivitendo-erp.git 3-arg open: Mode für zu öffnende Pipes separat sichern Druckvorlagen mit temporären Zwischenergebnissen werden erst mit mode ">" in eine Temp-Datei geschrieben, und dann über die ursprüngliche Pipe ausgegeben. Der Mode für die Datei muss dabei separat gehandhabt werden. --- diff --git a/SL/Form.pm b/SL/Form.pm index eaee0965a..dc20d2ce6 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1237,7 +1237,7 @@ sub parse_template { $main::lxdebug->enter_sub(); my ($self, $myconfig) = @_; - my $out; + my ($out, $out_mode); local (*IN, *OUT); @@ -1319,13 +1319,15 @@ sub parse_template { if ($template->uses_temp_file() || $self->{media} eq 'email') { $out = $self->{OUT}; + $out_mode = $self->{OUT_MODE} || '>'; $self->{OUT} = "$self->{tmpfile}"; + $self->{OUT_MODE} = '>'; } my $result; if ($self->{OUT}) { - open(OUT, ">", $self->{OUT}) or $self->error("$self->{OUT} : $!"); + open(OUT, $self->{OUT_MODE}, $self->{OUT}) or $self->error("error on opening $self->{OUT} with mode $self->{OUT_MODE} : $!"); } else { *OUT = ($::dispatcher->get_standard_filehandles)[1]; $self->header; @@ -1398,7 +1400,8 @@ sub parse_template { } else { - $self->{OUT} = $out; + $self->{OUT} = $out; + $self->{OUT_MODE} = $out_mode; my $numbytes = (-s $self->{tmpfile}); open(IN, "<", $self->{tmpfile}) @@ -1412,7 +1415,7 @@ sub parse_template { #print(STDERR "OUT $self->{OUT}\n"); for my $i (1 .. $self->{copies}) { if ($self->{OUT}) { - open OUT, '>', $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); + open OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); print OUT $_ while ; close OUT; seek IN, 0, 0; diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index c34913a71..940fec968 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1481,9 +1481,10 @@ sub print_form { if ($form->{media} eq 'printer') { #$form->{OUT} = "| $form->{printer_command} &>/dev/null"; - $form->{OUT} = "| $form->{printer_command} "; + $form->{OUT} = $form->{printer_command}; + $form->{OUT_MODE} = '|-'; $form->{printed} .= " $form->{formname}"; - $form->{printed} =~ s/^ //; + $form->{printed} =~ s/^ //; } my $printed = $form->{printed}; @@ -1510,7 +1511,8 @@ sub print_form { } $filename .= ($form->{postscript}) ? '.ps' : '.pdf'; - $form->{OUT} = ">" . $::lx_office_conf{paths}->{spool} . "/$filename"; + $form->{OUT} = $::lx_office_conf{paths}->{spool} . "/$filename"; + $form->{OUT_MODE} = '>'; # add type $form->{queued} .= " $form->{formname} $filename";