Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 20069819

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 20069819d0de7313f5f6fcc724d0ea35d8fd0bd6
  • Vorgänger 53c26ac2
  • Nachfolger 91ea4ec2

Beim Drucken immer zuerst in temporäre Datei speichern

Unterschiede anzeigen:

SL/Form.pm
1044 1044
  close $temp_fh;
1045 1045
  (undef, undef, $self->{template_meta}{tmpfile}) = File::Spec->splitpath( $self->{tmpfile} );
1046 1046

  
1047
  if ($template->uses_temp_file() || $self->{media} eq 'email') {
1048
    $out              = $self->{OUT};
1049
    $out_mode         = $self->{OUT_MODE} || '>';
1050
    $self->{OUT}      = "$self->{tmpfile}";
1051
    $self->{OUT_MODE} = '>';
1052
  }
1047
  $out              = $self->{OUT};
1048
  $out_mode         = $self->{OUT_MODE} || '>';
1049
  $self->{OUT}      = "$self->{tmpfile}";
1050
  $self->{OUT_MODE} = '>';
1053 1051

  
1054 1052
  my $result;
1055 1053
  my $command_formatter = sub {
......
1085 1083
    return;
1086 1084
  }
1087 1085

  
1088
  if ($template->uses_temp_file() || $self->{media} eq 'email') {
1089

  
1090
    if ($self->{media} eq 'email') {
1086
  if ($self->{media} eq 'email') {
1091 1087

  
1092
      my $mail = new Mailer;
1088
    my $mail = new Mailer;
1093 1089

  
1094
      map { $mail->{$_} = $self->{$_} }
1095
        qw(cc bcc subject message version format);
1096
      $mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email};
1097
      $mail->{from}   = qq|"$myconfig->{name}" <$myconfig->{email}>|;
1098
      $mail->{fileid} = time() . '.' . $$ . '.';
1099
      $myconfig->{signature} =~ s/\r//g;
1090
    map { $mail->{$_} = $self->{$_} }
1091
      qw(cc bcc subject message version format);
1092
    $mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email};
1093
    $mail->{from}   = qq|"$myconfig->{name}" <$myconfig->{email}>|;
1094
    $mail->{fileid} = time() . '.' . $$ . '.';
1095
    $myconfig->{signature} =~ s/\r//g;
1100 1096

  
1101
      # if we send html or plain text inline
1102
      if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) {
1103
        $mail->{contenttype}    =  "text/html";
1104
        $mail->{message}        =~ s/\r//g;
1105
        $mail->{message}        =~ s/\n/<br>\n/g;
1106
        $myconfig->{signature}  =~ s/\n/<br>\n/g;
1107
        $mail->{message}       .=  "<br>\n-- <br>\n$myconfig->{signature}\n<br>";
1097
    # if we send html or plain text inline
1098
    if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) {
1099
      $mail->{contenttype}    =  "text/html";
1100
      $mail->{message}        =~ s/\r//g;
1101
      $mail->{message}        =~ s/\n/<br>\n/g;
1102
      $myconfig->{signature}  =~ s/\n/<br>\n/g;
1103
      $mail->{message}       .=  "<br>\n-- <br>\n$myconfig->{signature}\n<br>";
1108 1104

  
1109
        open(IN, "<", $self->{tmpfile})
1110
          or $self->error($self->cleanup . "$self->{tmpfile} : $!");
1111
        $mail->{message} .= $_ while <IN>;
1112
        close(IN);
1105
      open(IN, "<", $self->{tmpfile})
1106
        or $self->error($self->cleanup . "$self->{tmpfile} : $!");
1107
      $mail->{message} .= $_ while <IN>;
1108
      close(IN);
1113 1109

  
1114
      } else {
1110
    } else {
1115 1111

  
1116
        if (!$self->{"do_not_attach"}) {
1117
          my $attachment_name  =  $self->{attachment_filename} || $self->{tmpfile};
1118
          $attachment_name     =~ s/\.(.+?)$/.${ext_for_format}/ if ($ext_for_format);
1119
          $mail->{attachments} =  [{ "filename" => $self->{tmpfile},
1120
                                     "name"     => $attachment_name }];
1121
        }
1112
      if (!$self->{"do_not_attach"}) {
1113
        my $attachment_name  =  $self->{attachment_filename} || $self->{tmpfile};
1114
        $attachment_name     =~ s/\.(.+?)$/.${ext_for_format}/ if ($ext_for_format);
1115
        $mail->{attachments} =  [{ "filename" => $self->{tmpfile},
1116
                                   "name"     => $attachment_name }];
1117
      }
1122 1118

  
1123
        $mail->{message}  =~ s/\r//g;
1124
        $mail->{message} .=  "\n-- \n$myconfig->{signature}";
1119
      $mail->{message}  =~ s/\r//g;
1120
      $mail->{message} .=  "\n-- \n$myconfig->{signature}";
1125 1121

  
1126
      }
1122
    }
1127 1123

  
1128
      my $err = $mail->send();
1129
      $self->error($self->cleanup . "$err") if ($err);
1124
    my $err = $mail->send();
1125
    $self->error($self->cleanup . "$err") if ($err);
1130 1126

  
1131
    } else {
1127
  } else {
1132 1128

  
1133
      $self->{OUT}      = $out;
1134
      $self->{OUT_MODE} = $out_mode;
1129
    $self->{OUT}      = $out;
1130
    $self->{OUT_MODE} = $out_mode;
1135 1131

  
1136
      my $numbytes = (-s $self->{tmpfile});
1137
      open(IN, "<", $self->{tmpfile})
1138
        or $self->error($self->cleanup . "$self->{tmpfile} : $!");
1139
      binmode IN;
1132
    my $numbytes = (-s $self->{tmpfile});
1133
    open(IN, "<", $self->{tmpfile})
1134
      or $self->error($self->cleanup . "$self->{tmpfile} : $!");
1135
    binmode IN;
1140 1136

  
1141
      $self->{copies} = 1 unless $self->{media} eq 'printer';
1137
    $self->{copies} = 1 unless $self->{media} eq 'printer';
1142 1138

  
1143
      chdir("$self->{cwd}");
1144
      #print(STDERR "Kopien $self->{copies}\n");
1145
      #print(STDERR "OUT $self->{OUT}\n");
1146
      for my $i (1 .. $self->{copies}) {
1147
        if ($self->{OUT}) {
1148
          $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT});
1139
    chdir("$self->{cwd}");
1140
    #print(STDERR "Kopien $self->{copies}\n");
1141
    #print(STDERR "OUT $self->{OUT}\n");
1142
    for my $i (1 .. $self->{copies}) {
1143
      if ($self->{OUT}) {
1144
        $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT});
1149 1145

  
1150
          open  OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!");
1151
          print OUT $_ while <IN>;
1152
          close OUT;
1153
          seek  IN, 0, 0;
1146
        open  OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!");
1147
        print OUT $_ while <IN>;
1148
        close OUT;
1149
        seek  IN, 0, 0;
1154 1150

  
1155
        } else {
1156
          $self->{attachment_filename} = ($self->{attachment_filename})
1157
                                       ? $self->{attachment_filename}
1158
                                       : $self->generate_attachment_filename();
1151
      } else {
1152
        $self->{attachment_filename} = ($self->{attachment_filename})
1153
                                     ? $self->{attachment_filename}
1154
                                     : $self->generate_attachment_filename();
1159 1155

  
1160
          # launch application
1161
          print qq|Content-Type: | . $template->get_mime_type() . qq|
1156
        # launch application
1157
        print qq|Content-Type: | . $template->get_mime_type() . qq|
1162 1158
Content-Disposition: attachment; filename="$self->{attachment_filename}"
1163 1159
Content-Length: $numbytes
1164 1160

  
1165 1161
|;
1166 1162

  
1167
          $::locale->with_raw_io(\*STDOUT, sub { print while <IN> });
1168
        }
1163
        $::locale->with_raw_io(\*STDOUT, sub { print while <IN> });
1169 1164
      }
1170

  
1171
      close(IN);
1172 1165
    }
1173 1166

  
1167
    close(IN);
1174 1168
  }
1175 1169

  
1176 1170
  $self->cleanup;

Auch abrufbar als: Unified diff