X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FREST%2F1.0%2FForms%2Fticket%2Fcomment;h=87d7dc815435bd8c88cffcebf0e3df826a974e50;hp=c8d548adbaeb0e0a6ed57ef3d0461e52c90f5060;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c diff --git a/rt/share/html/REST/1.0/Forms/ticket/comment b/rt/share/html/REST/1.0/Forms/ticket/comment index c8d548adb..87d7dc815 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/comment +++ b/rt/share/html/REST/1.0/Forms/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -53,14 +53,12 @@ $id <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); $RT::Logger->debug("Got ticket id=$id for comment"); $RT::Logger->debug("Got args @{[keys(%changes)]}."); -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my ($c, $o, $k, $e) = ("", [], {}, 0); # http://.../REST/1.0/ticket/1/comment @@ -88,40 +86,24 @@ if (!$changes{Text} && @atts == 0) { goto OUTPUT; } -my $cgi = $m->cgi_object; -my $ent = MIME::Entity->build(Type => "multipart/mixed"); -$ent->attach(Data => $changes{Text}) if $changes{Text}; +my $ent = MIME::Entity->build( + Type => "multipart/mixed", + 'X-RT-Interface' => 'REST', +); +$ent->attach( + Type => $changes{'Content-Type'} || 'text/plain', + Charset => "UTF-8", + Data => Encode::encode("UTF-8", $changes{Text} ), +) if $changes{Text}; -my $i = 1; -foreach my $att (@atts) { - local $/=undef; - my $file = $att; - $file =~ s#^.*[\\/]##; - my $fh = $cgi->upload("attachment_$i"); - if ($fh) { - my $buf; - my ($w, $tmp) = tempfile(); - my $info = $cgi->uploadInfo($fh); - - while (sysread($fh, $buf, 8192)) { - syswrite($w, $buf); - } - - $ent->attach( - Path => $tmp, - Type => $info->{'Content-Type'} || guess_media_type($tmp), - Filename => $file, - Disposition => "attachment" - ); - } - else { +{ + my ($status, $msg) = process_attachments($ent, @atts); + unless ( $status ) { $e = 1; - $c = "# No attachment for $att."; + $c = "# $msg"; goto OUTPUT; } - - $i++; } unless ($ticket->CurrentUserHasRight('ModifyTicket') || @@ -148,5 +130,6 @@ if ($changes{Status}) { } OUTPUT: + return [ $c, $o, $k, $e ];