summaryrefslogtreecommitdiff
path: root/rt/share/html/REST/1.0/Forms/ticket
diff options
context:
space:
mode:
Diffstat (limited to 'rt/share/html/REST/1.0/Forms/ticket')
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/attachments2
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/comment43
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/default44
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/history2
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/links2
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/merge2
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/take2
7 files changed, 45 insertions, 52 deletions
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
%# <sales@bestpractical.com>
%#
%# (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
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -53,10 +53,7 @@ $id
</%ARGS>
<%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 ];
</%INIT>
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
%# <sales@bestpractical.com>
%#
%# (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
%# <sales@bestpractical.com>
%#
%# (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
%# <sales@bestpractical.com>
%#
%# (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
%# <sales@bestpractical.com>
%#
%# (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
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)