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/attachments9
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/comment4
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/default61
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/history11
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/links11
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/merge6
-rwxr-xr-xrt/share/html/REST/1.0/Forms/ticket/take4
7 files changed, 64 insertions, 42 deletions
diff --git a/rt/share/html/REST/1.0/Forms/ticket/attachments b/rt/share/html/REST/1.0/Forms/ticket/attachments
index ac141615d..43b8ed85a 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-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -54,7 +54,7 @@ $args => undef
<%INIT>
my @data;
my ($c, $o, $k, $e) = ("", [], {}, "");
-my $ticket = new RT::Ticket $session{CurrentUser};
+my $ticket = RT::Ticket->new($session{CurrentUser});
$ticket->Load($id);
unless ($ticket->Id) {
@@ -76,7 +76,7 @@ if ($aid) {
unless ($aid =~ /^\d+$/) {
return [ "# Invalid attachment id: $aid", [], {}, 1 ];
}
- my $attachment = new RT::Attachment $session{CurrentUser};
+ my $attachment = RT::Attachment->new($session{CurrentUser});
$attachment->Load($aid);
unless ($attachment->Id eq $aid) {
return [ "# Invalid attachment id: $aid", [], {}, 1 ];
@@ -118,7 +118,8 @@ else {
my $size = length($a->Content || '');
if ($size > 1024) { $size = int($size/102.4)/10 . "k" }
else { $size .= "b" }
- push @attachments, $a->Id.": ".($a->Filename || '(Unnamed)')." (".$a->ContentType . " / ".$size.")";
+ my $name = (defined $a->Filename and length $a->Filename) ? $a->Filename : "(Unnamed)";
+ push @attachments, $a->Id.": $name (".$a->ContentType . " / $size)";
}
}
diff --git a/rt/share/html/REST/1.0/Forms/ticket/comment b/rt/share/html/REST/1.0/Forms/ticket/comment
index c8d548adb..35b543d9c 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-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -60,7 +60,7 @@ 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
diff --git a/rt/share/html/REST/1.0/Forms/ticket/default b/rt/share/html/REST/1.0/Forms/ticket/default
index 76635c85a..9a2212b55 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-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -62,7 +62,7 @@ my $cf_spec = RT::Interface::REST->custom_field_spec(1);
my @comments;
my ($c, $o, $k, $e) = ("", [], {}, 0);
my %data = %$changes;
-my $ticket = new RT::Ticket $session{CurrentUser};
+my $ticket = RT::Ticket->new($session{CurrentUser});
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
@@ -81,20 +81,27 @@ if ($id ne 'new') {
if (!$ticket->Id) {
return [ "# Ticket $id does not exist.", [], {}, 1 ];
}
- elsif (!$ticket->CurrentUserHasRight('ShowTicket') ||
- (%data && !$ticket->CurrentUserHasRight('ModifyTicket')))
- {
- my $act = %data ? "modify" : "display";
- return [ "# You are not allowed to $act ticket $id.", [], {}, 1 ];
+ elsif ( %data ) {
+ if ( $data{status} && $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 ];
+ }
+ }
+ elsif ( !$ticket->CurrentUserHasRight('ModifyTicket') ) {
+ return [ "# You are not allowed to modify ticket $id.", [], {}, 1 ];
+ }
+ }
+ elsif (!$ticket->CurrentUserHasRight('ShowTicket')) {
+ return [ "# You are not allowed to display ticket $id.", [], {}, 1 ];
}
}
else {
if (!keys(%data)) {
# GET ticket/new: Return a suitable default form.
# We get defaults from queue/1 (XXX: What if it isn't there?).
- my $due = new RT::Date $session{CurrentUser};
- my $queue = new RT::Queue $session{CurrentUser};
- my $starts = new RT::Date $session{CurrentUser};
+ my $due = RT::Date->new($session{CurrentUser});
+ my $queue = RT::Queue->new($session{CurrentUser});
+ my $starts = RT::Date->new($session{CurrentUser});
$queue->Load(1);
$due->SetToNow;
$due->AddDays($queue->DefaultDueIn) if $queue->DefaultDueIn;
@@ -132,7 +139,7 @@ else {
foreach my $k (keys %data) {
# flexibly parse any dates
if ($dates{lc $k}) {
- my $time = new RT::Date $session{CurrentUser};
+ my $time = RT::Date->new($session{CurrentUser});
$time->Set(Format => 'unknown', Value => $data{$k});
$data{$k} = $time->ISO;
}
@@ -142,10 +149,16 @@ else {
}
# Set custom field
elsif ($k =~ /^$cf_spec/) {
- my $cf = RT::CustomField->new( $RT::SystemUser );
- my $cfk = $1 || $2;
- unless($cf->LoadByName( Name => $cfk )) {
- push @comments, "# Invalid custom field name ($cfk)";
+ my $key = $1 || $2;
+
+ my $cf = RT::CustomField->new( $session{CurrentUser} );
+ $cf->LoadByName( Name => $key, Queue => $data{Queue} || $v{Queue} );
+ unless ( $cf->id ) {
+ $cf->LoadByName( Name => $key, Queue => 0 );
+ }
+
+ if (not $cf->id) {
+ push @comments, "# Invalid custom field name ($key)";
delete $data{$k};
next;
}
@@ -205,14 +218,14 @@ if (!keys(%data)) {
push @data, [ $key => [ $ticket->$key->MemberEmailAddresses ] ];
}
- $time = new RT::Date ($session{CurrentUser});
+ $time = RT::Date->new ($session{CurrentUser});
foreach $key (@dates) {
next unless (!%$fields || (exists $fields->{lc $key}));
$time->Set(Format => 'sql', Value => $ticket->$key);
push @data, [ $key => $time->AsString ];
}
- $time = new RT::Date ($session{CurrentUser});
+ $time = RT::Date->new ($session{CurrentUser});
foreach $key (qw(TimeEstimated TimeWorked TimeLeft)) {
next unless (!%$fields || (exists $fields->{lc $key}));
$val = $ticket->$key || 0;
@@ -280,7 +293,7 @@ else {
$key = $simple{$key};
$set = "Set$key";
- next if (($val eq $ticket->$key)|| ($ticket->$key =~ /^\d+$/ && $val == $ticket->$key));
+ next if (($val eq ($ticket->$key||''))|| ($ticket->$key =~ /^\d+$/ && $val =~ /^\d+$/ && $val == $ticket->$key));
($n, $s) = $ticket->$set("$val");
}
elsif (exists $dates{$key}) {
@@ -295,7 +308,7 @@ else {
$set = "Set$key";
- my $time = new RT::Date $session{CurrentUser};
+ my $time = RT::Date->new($session{CurrentUser});
$time->Set(Format => 'sql', Value => $ticket->$key);
next if ($val =~ /^not set$/i || $val eq $time->AsString);
@@ -341,9 +354,15 @@ else {
}
# Set custom field
elsif ($key =~ /^$cf_spec/) {
- my $cf = RT::CustomField->new( $RT::SystemUser );
$key = $1 || $2;
- if (not $cf->LoadByName( Name => $key )) {
+
+ my $cf = RT::CustomField->new( $session{CurrentUser} );
+ $cf->LoadByName( Name => $key, Queue => $ticket->Queue );
+ unless ( $cf->id ) {
+ $cf->LoadByName( Name => $key, Queue => 0 );
+ }
+
+ if (not $cf->id) {
$n = 0;
$s = "Unknown custom field.";
}
diff --git a/rt/share/html/REST/1.0/Forms/ticket/history b/rt/share/html/REST/1.0/Forms/ticket/history
index c2aa35a8e..8b6e01722 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-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -54,7 +54,7 @@ $format => undef
$fields => undef
</%ARGS>
<%INIT>
-my $ticket = new RT::Ticket $session{CurrentUser};
+my $ticket = RT::Ticket->new($session{CurrentUser});
my ($c, $o, $k, $e) = ("", [], {}, "");
$ticket->Load($id);
@@ -100,7 +100,7 @@ if ($type) {
if ($tid) {
my @data;
- my $t = new RT::Transaction $session{CurrentUser};
+ my $t = RT::Transaction->new($session{CurrentUser});
# this paragraph limits the transaction ID query to transactions on this ticket.
# Otherwise you can query any transaction from any ticket, which makes no sense.
@@ -137,7 +137,7 @@ if ($tid) {
if (!%$fields || exists $fields->{lc 'Content'}) {
- my $creator = new RT::User $session{CurrentUser};
+ my $creator = RT::User->new($session{CurrentUser});
$creator->Load($t->Creator);
push @data, [ Creator => $creator->Name ];
}
@@ -151,7 +151,8 @@ if ($tid) {
my $size = length($a->Content||'');
if ($size > 1024) { $size = int($size/102.4)/10 . "k" }
else { $size .= "b" }
- $attachlist .= "\n" . $a->Id.": ".($a->Filename || "untitled")." (".$size.")";
+ my $name = (defined $a->Filename and length $a->Filename) ? $a->Filename : "untitled";
+ $attachlist .= "\n" . $a->Id.": $name ($size)";
}
push @data, [Attachments => $attachlist];
diff --git a/rt/share/html/REST/1.0/Forms/ticket/links b/rt/share/html/REST/1.0/Forms/ticket/links
index fb9ee8fe1..bf4f2575c 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-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -54,7 +54,7 @@ $changes => undef
</%ARGS>
<%INIT>
my @data;
-my $ticket = new RT::Ticket $session{CurrentUser};
+my $ticket = RT::Ticket->new($session{CurrentUser});
$ticket->Load($id);
if (!$ticket->Id) {
@@ -96,11 +96,12 @@ if ($changes) {
my %new;
foreach my $nkey (@{vsplit($val)}) {
if ($nkey =~ /^\d+$/) {
- my $uri = new RT::URI $session{CurrentUser};
- my $tick = new RT::Ticket $session{CurrentUser};
+ my $uri = RT::URI->new($session{CurrentUser});
+ my $tick = RT::Ticket->new($session{CurrentUser});
$tick->Load($nkey);
if ($tick->Id) {
- $nkey = $uri->FromObject($tick);
+ $uri->FromObject($tick);
+ $nkey = $uri->URI;
}
else {
$n = 0;
diff --git a/rt/share/html/REST/1.0/Forms/ticket/merge b/rt/share/html/REST/1.0/Forms/ticket/merge
index 360ddd702..a751dc558 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-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -56,8 +56,8 @@ use RT::Interface::REST;
my $into = $args;
-my $ticket = new RT::Ticket $session{CurrentUser};
-my $ticket_into = new RT::Ticket $session{CurrentUser};
+my $ticket = RT::Ticket->new($session{CurrentUser});
+my $ticket_into = RT::Ticket->new($session{CurrentUser});
my ($c, $o, $k, $e) = ("", [], {}, 0);
# http://.../REST/1.0/ticket/1/merge/6 (merges ticket 1 into ticket 6)
diff --git a/rt/share/html/REST/1.0/Forms/ticket/take b/rt/share/html/REST/1.0/Forms/ticket/take
index d0bf13e3a..503ba55f0 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-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -54,7 +54,7 @@ $id
<%INIT>
use RT::Interface::REST;
-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/take