From 45d35d5739d05e602bc317739485693e0e9ff0b5 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 25 Feb 2014 18:34:25 -0800 Subject: RT 4.0.19 --- rt/share/html/REST/1.0/Forms/attachment/default | 2 +- rt/share/html/REST/1.0/Forms/group/customfields | 2 +- rt/share/html/REST/1.0/Forms/group/default | 9 +++-- rt/share/html/REST/1.0/Forms/group/ns | 2 +- rt/share/html/REST/1.0/Forms/queue/customfields | 2 +- rt/share/html/REST/1.0/Forms/queue/default | 9 +++-- rt/share/html/REST/1.0/Forms/queue/ns | 2 +- .../html/REST/1.0/Forms/queue/ticketcustomfields | 2 +- rt/share/html/REST/1.0/Forms/ticket/attachments | 2 +- rt/share/html/REST/1.0/Forms/ticket/comment | 43 +++++---------------- rt/share/html/REST/1.0/Forms/ticket/default | 44 +++++++++++++++------- rt/share/html/REST/1.0/Forms/ticket/history | 2 +- rt/share/html/REST/1.0/Forms/ticket/links | 2 +- rt/share/html/REST/1.0/Forms/ticket/merge | 2 +- rt/share/html/REST/1.0/Forms/ticket/take | 2 +- rt/share/html/REST/1.0/Forms/transaction/default | 2 +- rt/share/html/REST/1.0/Forms/user/default | 9 +++-- rt/share/html/REST/1.0/Forms/user/ns | 2 +- rt/share/html/REST/1.0/NoAuth/mail-gateway | 2 +- rt/share/html/REST/1.0/autohandler | 2 +- rt/share/html/REST/1.0/dhandler | 2 +- rt/share/html/REST/1.0/logout | 2 +- rt/share/html/REST/1.0/search/dhandler | 2 +- rt/share/html/REST/1.0/search/ticket | 2 +- rt/share/html/REST/1.0/ticket/comment | 38 +++---------------- rt/share/html/REST/1.0/ticket/link | 2 +- rt/share/html/REST/1.0/ticket/merge | 2 +- 27 files changed, 84 insertions(+), 110 deletions(-) (limited to 'rt/share/html/REST/1.0') diff --git a/rt/share/html/REST/1.0/Forms/attachment/default b/rt/share/html/REST/1.0/Forms/attachment/default index 80039cee2..8c6cf3ec8 100644 --- a/rt/share/html/REST/1.0/Forms/attachment/default +++ b/rt/share/html/REST/1.0/Forms/attachment/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/group/customfields b/rt/share/html/REST/1.0/Forms/group/customfields index 1dba6ccd8..5fb4730b0 100644 --- a/rt/share/html/REST/1.0/Forms/group/customfields +++ b/rt/share/html/REST/1.0/Forms/group/customfields @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/group/default b/rt/share/html/REST/1.0/Forms/group/default index 8867bf938..ffbd9dbf3 100644 --- a/rt/share/html/REST/1.0/Forms/group/default +++ b/rt/share/html/REST/1.0/Forms/group/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -156,7 +156,7 @@ if (%data == 0) { } else { my ($get, $set, $key, $val, $n, $s); - + my $updated; foreach $key (keys %data) { $val = $data{$key}; $key = lc $key; @@ -192,9 +192,12 @@ else { $k = $changes; } } + else { + $updated ||= 1; + } } - push(@comments, "# Group $id updated.") unless $n == 0; + push(@comments, "# Group $id updated.") if $updated; } DONE: diff --git a/rt/share/html/REST/1.0/Forms/group/ns b/rt/share/html/REST/1.0/Forms/group/ns index 907324de5..c993db8b6 100644 --- a/rt/share/html/REST/1.0/Forms/group/ns +++ b/rt/share/html/REST/1.0/Forms/group/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/queue/customfields b/rt/share/html/REST/1.0/Forms/queue/customfields index 9ebabb065..79ab07531 100644 --- a/rt/share/html/REST/1.0/Forms/queue/customfields +++ b/rt/share/html/REST/1.0/Forms/queue/customfields @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/queue/default b/rt/share/html/REST/1.0/Forms/queue/default index 58bb89953..48e4fba7f 100755 --- a/rt/share/html/REST/1.0/Forms/queue/default +++ b/rt/share/html/REST/1.0/Forms/queue/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -146,7 +146,7 @@ if ( keys %data == 0) { } else { my ($get, $set, $key, $val, $n, $s); - + my $updated; foreach $key (keys %data) { $val = $data{$key}; $key = lc $key; @@ -175,9 +175,12 @@ else { $k = $changes; } } + else { + $updated ||= 1; + } } - push(@comments, "# Queue $id updated.") unless $n == 0; + push(@comments, "# Queue $id updated.") if $updated; } DONE: diff --git a/rt/share/html/REST/1.0/Forms/queue/ns b/rt/share/html/REST/1.0/Forms/queue/ns index 3ea6bf261..5a3e09f8a 100755 --- a/rt/share/html/REST/1.0/Forms/queue/ns +++ b/rt/share/html/REST/1.0/Forms/queue/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields b/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields index c38f3beb3..038f1881d 100644 --- a/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields +++ b/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/ticket/attachments b/rt/share/html/REST/1.0/Forms/ticket/attachments index ba3a24825..43df839af 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/attachments +++ b/rt/share/html/REST/1.0/Forms/ticket/attachments @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/ticket/comment b/rt/share/html/REST/1.0/Forms/ticket/comment index b50135fec..934cbfb68 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-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -53,10 +53,7 @@ $id <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); -my @tmp_files; $RT::Logger->debug("Got ticket id=$id for comment"); $RT::Logger->debug("Got args @{[keys(%changes)]}."); @@ -89,44 +86,23 @@ if (!$changes{Text} && @atts == 0) { goto OUTPUT; } -my $cgi = $m->cgi_object; my $ent = MIME::Entity->build( Type => "multipart/mixed", 'X-RT-Interface' => 'REST', ); -$ent->attach(Data => $changes{Text}) if $changes{Text}; +$ent->attach( + 'Content-Type' => $changes{'Content-Type'} || 'text/plain', + Data => $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); - push @tmp_files, $tmp; - - 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') || @@ -154,6 +130,5 @@ if ($changes{Status}) { OUTPUT: -unlink @tmp_files; return [ $c, $o, $k, $e ]; diff --git a/rt/share/html/REST/1.0/Forms/ticket/default b/rt/share/html/REST/1.0/Forms/ticket/default index 0bced1e99..2a0c7efa4 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/default +++ b/rt/share/html/REST/1.0/Forms/ticket/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -67,7 +67,7 @@ my @dates = qw(Created Starts Started Due Resolved Told LastUpdated); my @people = qw(Requestors Cc AdminCc); my @create = qw(Queue Requestor Subject Cc AdminCc Owner Status Priority InitialPriority FinalPriority TimeEstimated TimeWorked - TimeLeft Starts Started Due Resolved); + TimeLeft Starts Started Due Resolved Content-Type); my @simple = qw(Subject Status Priority Disabled TimeEstimated TimeWorked TimeLeft InitialPriority FinalPriority); my %dates = map {lc $_ => $_} @dates; @@ -82,7 +82,7 @@ if ($id ne 'new') { return [ "# Ticket $id does not exist.", [], {}, 1 ]; } elsif ( %data ) { - if ( $data{status} && $data{status} eq 'deleted' && ! grep { $_ ne 'id' && $_ ne 'status' } keys %data ) { + if ( $data{status} && lc $data{status} eq 'deleted' && ! grep { $_ ne 'id' && $_ ne 'status' } keys %data ) { if ( !$ticket->CurrentUserHasRight('DeleteTicket') ) { return [ "# You are not allowed to delete ticket $id.", [], {}, 1 ]; } @@ -110,7 +110,7 @@ else { return [ "# Required: id, Queue", [ qw(id Queue Requestor Subject Cc AdminCc Owner Status Priority - InitialPriority FinalPriority TimeEstimated Starts Due Text) ], + InitialPriority FinalPriority TimeEstimated Starts Due Attachment Text) ], { id => "ticket/new", Queue => $queue->Name, @@ -126,6 +126,7 @@ else { TimeEstimated => 0, Starts => $starts->ISO, Due => $due->ISO, + Attachment => '', Text => "", }, 0 @@ -134,7 +135,7 @@ else { else { # We'll create a new ticket, and fall through to set fields that # can't be set in the call to Create(). - my (%v, $text); + my (%v, $text, @atts); foreach my $k (keys %data) { # flexibly parse any dates @@ -167,6 +168,9 @@ else { elsif (lc $k eq 'text') { $text = delete $data{$k}; } + elsif (lc $k eq 'attachment') { + push @atts, @{ vsplit(delete $data{$k}) }; + } elsif ( $k !~ /^(?:id|requestors)$/i ) { $e = 1; push @$o, $k; @@ -183,14 +187,24 @@ else { # people fields allow multiple values $v{$_} = vsplit($v{$_}) foreach ( grep $create{lc $_}, @people ); - if ($text) { + if ($text || @atts) { $v{MIMEObj} = MIME::Entity->build( + Type => "multipart/mixed", From => $session{CurrentUser}->EmailAddress, Subject => $v{Subject}, - Data => $text, 'X-RT-Interface' => 'REST', ); + $v{MIMEObj}->attach( + Data => $text, + 'Content-Type' => $v{'Content-Type'} || 'text/plain', + ) if $text; + my ($status, $msg) = process_attachments($v{'MIMEObj'}, @atts); + unless ($status) { + push(@comments, "# $msg"); + goto DONE; + } + $v{MIMEObj}->make_singlepart; } my($tid,$trid,$terr) = $ticket->Create(%v); @@ -279,6 +293,7 @@ if (!keys(%data)) { } else { my ($get, $set, $key, $val, $n, $s); + my $updated; foreach $key (keys %data) { $val = $data{$key}; @@ -416,14 +431,14 @@ else { $s =~ s/\\'/'/g; push @new, $s; } - elsif ( $a =~ /^q{/ ) { + elsif ( $a =~ /^q\{/ ) { my $s = $a; - while ( $a !~ /}$/ ) { + while ( $a !~ /\}$/ ) { ( $a, $b ) = split /\s*,\s*/, $b, 2; $s .= ',' . $a; } - $s =~ s/^q{//; - $s =~ s/}//; + $s =~ s/^q\{//; + $s =~ s/\}//; push @new, $s; } else { @@ -454,7 +469,7 @@ else { } } } - elsif ($key ne 'id' && $key ne 'type' && $key ne 'creator') { + elsif ($key ne 'id' && $key ne 'type' && $key ne 'creator' && $key ne 'content-type' ) { $n = 0; $s = "Unknown field."; } @@ -469,8 +484,11 @@ else { $k = $changes; } } + else { + $updated ||= 1; + } } - push(@comments, "# Ticket ".$ticket->id." updated.") unless $n == 0; + push(@comments, "# Ticket ".$ticket->id." updated.") if $updated; } DONE: diff --git a/rt/share/html/REST/1.0/Forms/ticket/history b/rt/share/html/REST/1.0/Forms/ticket/history index ec4f08150..debfcc85c 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/history +++ b/rt/share/html/REST/1.0/Forms/ticket/history @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/ticket/links b/rt/share/html/REST/1.0/Forms/ticket/links index 32e072457..45b14d015 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/links +++ b/rt/share/html/REST/1.0/Forms/ticket/links @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/ticket/merge b/rt/share/html/REST/1.0/Forms/ticket/merge index db25bdfe2..fdc224423 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/merge +++ b/rt/share/html/REST/1.0/Forms/ticket/merge @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/ticket/take b/rt/share/html/REST/1.0/Forms/ticket/take index e30cd84b6..b5a536270 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/take +++ b/rt/share/html/REST/1.0/Forms/ticket/take @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/transaction/default b/rt/share/html/REST/1.0/Forms/transaction/default index 2cc10d1aa..adcf3438f 100644 --- a/rt/share/html/REST/1.0/Forms/transaction/default +++ b/rt/share/html/REST/1.0/Forms/transaction/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/Forms/user/default b/rt/share/html/REST/1.0/Forms/user/default index c11263693..046154768 100755 --- a/rt/share/html/REST/1.0/Forms/user/default +++ b/rt/share/html/REST/1.0/Forms/user/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -136,7 +136,7 @@ if (keys %data == 0) { } else { my ($get, $set, $key, $val, $n, $s); - + my $updated; foreach $key (keys %data) { $val = $data{$key}; $key = lc $key; @@ -177,9 +177,12 @@ else { $k = $changes; } } + else { + $updated ||= 1; + } } - push(@comments, "# User $id updated.") unless $n == 0; + push(@comments, "# User $id updated.") if $updated; } DONE: diff --git a/rt/share/html/REST/1.0/Forms/user/ns b/rt/share/html/REST/1.0/Forms/user/ns index 161372493..84a668503 100755 --- a/rt/share/html/REST/1.0/Forms/user/ns +++ b/rt/share/html/REST/1.0/Forms/user/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/NoAuth/mail-gateway b/rt/share/html/REST/1.0/NoAuth/mail-gateway index dec5ce71f..cd4271417 100755 --- a/rt/share/html/REST/1.0/NoAuth/mail-gateway +++ b/rt/share/html/REST/1.0/NoAuth/mail-gateway @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/autohandler b/rt/share/html/REST/1.0/autohandler index b50bf6aac..03f70e052 100755 --- a/rt/share/html/REST/1.0/autohandler +++ b/rt/share/html/REST/1.0/autohandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/dhandler b/rt/share/html/REST/1.0/dhandler index 49a28c636..7ade8fa53 100755 --- a/rt/share/html/REST/1.0/dhandler +++ b/rt/share/html/REST/1.0/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/logout b/rt/share/html/REST/1.0/logout index 4ce4d8294..4dbb098bd 100755 --- a/rt/share/html/REST/1.0/logout +++ b/rt/share/html/REST/1.0/logout @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/search/dhandler b/rt/share/html/REST/1.0/search/dhandler index 677a632f6..c247bd3ed 100755 --- a/rt/share/html/REST/1.0/search/dhandler +++ b/rt/share/html/REST/1.0/search/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/search/ticket b/rt/share/html/REST/1.0/search/ticket index a0e65d070..f7b8f4c5a 100755 --- a/rt/share/html/REST/1.0/search/ticket +++ b/rt/share/html/REST/1.0/search/ticket @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/ticket/comment b/rt/share/html/REST/1.0/ticket/comment index 475e3a88d..4c058b6ab 100755 --- a/rt/share/html/REST/1.0/ticket/comment +++ b/rt/share/html/REST/1.0/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -52,10 +52,7 @@ $content <%INIT> use MIME::Entity; -use LWP::MediaTypes; use RT::Interface::REST; -use File::Temp qw(tempfile); -my @tmp_files; my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; @@ -113,37 +110,13 @@ my $ent = MIME::Entity->build( ); $ent->attach(Data => $k->{Text}) if $k->{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(); - push @tmp_files, $tmp; - my $info = $cgi->uploadInfo(); - - 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 ($res, $msg) = process_attachments($ent, @atts); + unless ( $res ) { $status = "400 Bad Request"; - $output = "No attachment for $att.\n"; + $output = "$msg\n"; goto OUTPUT; } - - $i++; } $ticket->Load($object); @@ -177,7 +150,6 @@ if ($k->{Status}) { OUTPUT: -unlink @tmp_files; RT/<% $RT::VERSION %> <% $status %> diff --git a/rt/share/html/REST/1.0/ticket/link b/rt/share/html/REST/1.0/ticket/link index 0b8b50692..023dc81db 100755 --- a/rt/share/html/REST/1.0/ticket/link +++ b/rt/share/html/REST/1.0/ticket/link @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/ticket/merge b/rt/share/html/REST/1.0/ticket/merge index 98cbaf7e4..ea96f6185 100755 --- a/rt/share/html/REST/1.0/ticket/merge +++ b/rt/share/html/REST/1.0/ticket/merge @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) -- cgit v1.2.1