diff options
Diffstat (limited to 'rt/html/REST')
-rw-r--r-- | rt/html/REST/1.0/Forms/queue/default | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/queue/ns | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/ticket/attachments | 17 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/ticket/default | 71 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/ticket/history | 27 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/ticket/links | 10 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/user/default | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/Forms/user/ns | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/NoAuth/mail-gateway | 19 | ||||
-rw-r--r-- | rt/html/REST/1.0/autohandler | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/dhandler | 21 | ||||
-rw-r--r-- | rt/html/REST/1.0/logout | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/search/dhandler | 6 | ||||
-rw-r--r-- | rt/html/REST/1.0/search/ticket | 31 | ||||
-rw-r--r-- | rt/html/REST/1.0/ticket/comment | 8 | ||||
-rw-r--r-- | rt/html/REST/1.0/ticket/link | 11 | ||||
-rw-r--r-- | rt/html/REST/1.0/ticket/merge | 6 |
17 files changed, 191 insertions, 72 deletions
diff --git a/rt/html/REST/1.0/Forms/queue/default b/rt/html/REST/1.0/Forms/queue/default index c87c33cce..cfc4b5291 100644 --- a/rt/html/REST/1.0/Forms/queue/default +++ b/rt/html/REST/1.0/Forms/queue/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/Forms/queue/ns b/rt/html/REST/1.0/Forms/queue/ns index b0ba0036a..227318944 100644 --- a/rt/html/REST/1.0/Forms/queue/ns +++ b/rt/html/REST/1.0/Forms/queue/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/Forms/ticket/attachments b/rt/html/REST/1.0/Forms/ticket/attachments index ca75ce0d1..4ee409bdc 100644 --- a/rt/html/REST/1.0/Forms/ticket/attachments +++ b/rt/html/REST/1.0/Forms/ticket/attachments @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -49,7 +51,7 @@ $id $args => undef </%ARGS> -<%perl> +<%INIT> my @data; my ($c, $o, $k, $e) = ("", [], {}, ""); my $ticket = new RT::Ticket $session{CurrentUser}; @@ -80,7 +82,12 @@ if ($aid) { return [ "# Invalid attachment id: $aid", [], {}, 1 ]; } if ($content) { - $c = $attachment->OriginalContent; + $c = $attachment->OriginalContent; + # if we're sending a binary attachment (and only the attachment) + # flag it so bin/rt knows to special case it + if ($attachment->ContentType !~ /^text\//) { + $r->content_type($attachment->ContentType); + } } else { my @data; push @data, [ id => $attachment->Id ]; @@ -125,4 +132,4 @@ else { } return [ $c, $o, $k, $e ]; -</%perl> +</%INIT> diff --git a/rt/html/REST/1.0/Forms/ticket/default b/rt/html/REST/1.0/Forms/ticket/default index 7d515e51f..2bfc43d9a 100644 --- a/rt/html/REST/1.0/Forms/ticket/default +++ b/rt/html/REST/1.0/Forms/ticket/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -49,8 +51,9 @@ $id $changes => {} $fields => undef +$args => undef </%ARGS> -<%perl> +<%INIT> use MIME::Entity; my @comments; @@ -83,7 +86,7 @@ if ($id ne 'new') { } } else { - if (%data == 0) { + 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}; @@ -127,11 +130,26 @@ else { if (exists $create{lc $k}) { $v{$create{lc $k}} = delete $data{$k}; } + # Set custom field + elsif ($k =~ /^CF-/i) { + my $cf = RT::CustomField->new( $RT::SystemUser ); + my $cfk = $k; + $cfk =~ s/^CF-//i; + unless($cf->LoadByName( Name => $cfk )) { + push @comments, "# Invalid custom field name ($cfk)"; + delete $data{$k}; + next; + } + $v{"CustomField-".$cf->Id()} = delete $data{$k}; + } elsif (lc $k eq 'text') { $text = delete $data{$k}; } } + # people fields allow multiple values + $v{$_} = vsplit($v{$_}) foreach ( grep $create{lc $_}, @people ); + if ($text) { $v{MIMEObj} = MIME::Entity->build( @@ -141,20 +159,23 @@ else { ); } - $ticket->Create(%v); - unless ($ticket->Id) { - return [ "# Could not create ticket.", [], {}, 1 ]; + my($tid,$trid,$terr) = $ticket->Create(%v); + unless ($tid) { + push(@comments, "# Could not create ticket."); + push(@comments, "# " . $terr); + goto DONE; } delete $data{id}; $id = $ticket->Id; push(@comments, "# Ticket $id created."); - goto DONE if %data == 0; + # see if the hash is empty + goto DONE if ! keys(%data); } } # Now we know we're dealing with an existing ticket. -if (%data == 0) { +if (!keys(%data)) { my ($time, $key, $val, @data); push @data, [ id => "ticket/".$ticket->Id ]; @@ -171,7 +192,7 @@ if (%data == 0) { } foreach $key (@people) { - next unless (!%$fields || (exists $fields->{lc $key})); + next unless (!%$fields || (exists $fields->{lc $key})); push @data, [ $key => [ $ticket->$key->MemberEmailAddresses ] ]; } @@ -186,10 +207,22 @@ if (%data == 0) { foreach $key (qw(TimeEstimated TimeWorked TimeLeft)) { next unless (!%$fields || (exists $fields->{lc $key})); $val = $ticket->$key || 0; - $val = $time->DurationAsString($val*60) if $val; + $val = "$val minutes" if $val; push @data, [ $key => $val ]; } + # Display custom fields + my $CustomFields = $ticket->QueueObj->TicketCustomFields(); + while (my $cf = $CustomFields->Next()) { + next unless (!%$fields || (exists $fields->{"cf-".lc $cf->Name})); + my $vals = $ticket->CustomFieldValues($cf->Id()); + my @out = (); + while (my $v = $vals->Next()) { + push @out, $v->Content; + } + push @data, [ 'CF-' . $cf->Name => join ',', @out ]; + } + my %k = map {@$_} @data; $o = [ map {$_->[0]} @data ]; $k = \%k; @@ -271,6 +304,20 @@ else { $s =~ s/^# //; } } + # Set custom field + elsif ($key =~ /^CF-/i) { + my $cf = RT::CustomField->new( $RT::SystemUser ); + $key =~ s/^CF-//i; + if (not $cf->LoadByName( Name => $key )) { + $n = 0; + $s = "Unknown custom field."; + } + else { + ($n, $s) = $ticket->AddCustomFieldValue( + Field => $cf, Value => $val ); + $s =~ s/^# // if defined $s; + } + } elsif ($key ne 'id' && $key ne 'type' && $key ne 'creator') { $n = 0; $s = "Unknown field."; @@ -295,4 +342,4 @@ DONE: $c ||= join("\n", @comments) if @comments; return [$c, $o, $k, $e]; -</%perl> +</%INIT> diff --git a/rt/html/REST/1.0/Forms/ticket/history b/rt/html/REST/1.0/Forms/ticket/history index 4663e97ee..5dd7417d0 100644 --- a/rt/html/REST/1.0/Forms/ticket/history +++ b/rt/html/REST/1.0/Forms/ticket/history @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -51,7 +53,7 @@ $args => undef $format => undef $fields => undef </%ARGS> -<%perl> +<%INIT> my $ticket = new RT::Ticket $session{CurrentUser}; my ($c, $o, $k, $e) = ("", [], {}, ""); @@ -94,7 +96,19 @@ if ($type) { if ($tid) { my @data; my $t = new RT::Transaction $session{CurrentUser}; - $t->Load($tid); + + # 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. + my $Transactions = $ticket->Transactions; + my $tok=0; + while (my $T = $Transactions->Next()) { + $tok=1 if ($T->Id == $tid) + } + if ($tok) { + $t->Load($tid); + } else { + return [ "# Transaction $tid is not related to Ticket $id", [], {}, 1 ]; + } push @data, [ id => $t->Id ]; push @data, [ Ticket => $t->Ticket ] @@ -168,8 +182,7 @@ if ($tid) { $fieldstring .= $key; } my ($content, $forms); - - $m->subexec("$RT::WebPath/REST/1.0/show", + $m->subexec("/REST/1.0/show", id => \@tid, format => $format, fields => $fieldstring); @@ -184,4 +197,4 @@ if (!$c) { return [ $c, $o, $k, $e ]; -</%perl> +</%INIT> diff --git a/rt/html/REST/1.0/Forms/ticket/links b/rt/html/REST/1.0/Forms/ticket/links index 9f14da4e3..6b2ed222d 100644 --- a/rt/html/REST/1.0/Forms/ticket/links +++ b/rt/html/REST/1.0/Forms/ticket/links @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -50,7 +52,7 @@ $id $format => 's' $changes => undef </%ARGS> -<%perl> +<%INIT> my @data; my $ticket = new RT::Ticket $session{CurrentUser}; @@ -167,4 +169,4 @@ else { } return [ $c, $o, $k, $e ]; -</%perl> +</%INIT> diff --git a/rt/html/REST/1.0/Forms/user/default b/rt/html/REST/1.0/Forms/user/default index ad2ebd57a..621e96dfa 100644 --- a/rt/html/REST/1.0/Forms/user/default +++ b/rt/html/REST/1.0/Forms/user/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/Forms/user/ns b/rt/html/REST/1.0/Forms/user/ns index 406156304..3503d8ace 100644 --- a/rt/html/REST/1.0/Forms/user/ns +++ b/rt/html/REST/1.0/Forms/user/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/NoAuth/mail-gateway b/rt/html/REST/1.0/NoAuth/mail-gateway index 65d55508d..739dace9d 100644 --- a/rt/html/REST/1.0/NoAuth/mail-gateway +++ b/rt/html/REST/1.0/NoAuth/mail-gateway @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -52,6 +54,7 @@ $action => "correspond" $ticket => undef </%ARGS> <%init> +$m->comp('/Elements/Callback', _CallbackName => 'Pre', %ARGS); use RT::Interface::Email (); # It's an exporter, but we don't care $r->content_type('text/plain; charset=utf-8'); $m->error_format('text'); @@ -59,13 +62,13 @@ my ( $status, $error, $Ticket ) = RT::Interface::Email::Gateway( \%ARGS ); if ( $status == 1 ) { $m->out('ok'); if ( $Ticket->Id ) { - $m->out( 'Ticket: ' . $Ticket->Id ); - $m->out( 'Queue: ' . $Ticket->QueueObj->Name ); - $m->out( 'Owner: ' . $Ticket->OwnerObj->Name ); - $m->out( 'Status: ' . $Ticket->Status ); - $m->out( 'Subject: ' . $Ticket->Subject ); + $m->out( 'Ticket: ' . ($Ticket->Id || '') ); + $m->out( 'Queue: ' . ($Ticket->QueueObj->Name || '') ); + $m->out( 'Owner: ' . ($Ticket->OwnerObj->Name || '') ); + $m->out( 'Status: ' . ($Ticket->Status || '') ); + $m->out( 'Subject: ' . ($Ticket->Subject || '') ); $m->out( - 'Requestor: ' . $Ticket->Requestors->MemberEmailAddressesAsString ); + 'Requestor: ' . ($Ticket->Requestors->MemberEmailAddressesAsString || '') ); } } else { diff --git a/rt/html/REST/1.0/autohandler b/rt/html/REST/1.0/autohandler index 8e3fb164d..e8247b18e 100644 --- a/rt/html/REST/1.0/autohandler +++ b/rt/html/REST/1.0/autohandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/dhandler b/rt/html/REST/1.0/dhandler index 6cf45b000..7406520bc 100644 --- a/rt/html/REST/1.0/dhandler +++ b/rt/html/REST/1.0/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -61,7 +63,7 @@ my $object = $m->dhandler_arg; my $name = qr{[\w.-]+}; my $list = '(?:(?:\d+-)?\d+,)*(?:\d+-)?\d+'; my $label = '[a-zA-Z0-9@_.+-]+'; -my $field = '[a-zA-Z][a-zA-Z0-9_-]*'; +my $field = '[a-zA-Z](?:[a-zA-Z0-9_-]|\s+)*'; my $labels = "(?:$label,)*$label"; # We must handle requests such as the following: @@ -72,6 +74,7 @@ my $labels = "(?:$label,)*$label"; # http://.../REST/1.0/ticket/edit # 4. http://.../REST/1.0/ticket/nn (all possibly with a single form). # http://.../REST/1.0/ticket/nn/history +# http://.../REST/1.0/ticket/nn/comment # http://.../REST/1.0/ticket/nn/attachment/1 # # Objects are specified by their type, and either a unique numeric ID, @@ -290,7 +293,12 @@ foreach $object (@objects) { # We won't pass $e through to compose, trusting instead that the # handler added suitable comments for the user. if ($e) { - $status = "409 Syntax Error" if @$o; + if (@$o) { + $status = "409 Syntax Error"; + } + else { + $status = "400 Bad Request"; + } push @output, [ $c, $o, $k ]; } else { @@ -303,7 +311,6 @@ unshift(@output, [ join "\n", @comments ]) if @comments; $output = form_compose(\@output); OUTPUT: +$m->out("RT/".$RT::VERSION ." ".$status ."\n\n$output\n") if ($output || $status != 200); +return; </%INIT> -RT/<% $RT::VERSION %> <% $status %> - -<% $output |n %> diff --git a/rt/html/REST/1.0/logout b/rt/html/REST/1.0/logout index 470cb0915..4152a7ee0 100644 --- a/rt/html/REST/1.0/logout +++ b/rt/html/REST/1.0/logout @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/search/dhandler b/rt/html/REST/1.0/search/dhandler index 1915a4644..3e6b314b7 100644 --- a/rt/html/REST/1.0/search/dhandler +++ b/rt/html/REST/1.0/search/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: diff --git a/rt/html/REST/1.0/search/ticket b/rt/html/REST/1.0/search/ticket index 0990fd69b..37883931d 100644 --- a/rt/html/REST/1.0/search/ticket +++ b/rt/html/REST/1.0/search/ticket @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -57,10 +59,10 @@ my $status = "200 Ok"; my $tickets = new RT::Tickets $session{CurrentUser}; # Parse and validate any field specifications. -my $field = '[a-zA-Z][a-zA-Z0-9_-]*'; +my $field = '[a-zA-Z](?:[a-zA-Z0-9_-]|\s+)*'; my (%fields, @fields); if ($fields) { - $format = "l"; + $format ||= "l"; unless ($fields =~ /^(?:$field,)*$field$/) { $status = "400 Bad Request"; $output = "Invalid field specification: $fields"; @@ -115,14 +117,28 @@ my @output; while (my $ticket = $tickets->Next) { $n++; + my $id = $ticket->Id; if ($format eq "i") { - $output .= "ticket/" . $ticket->Id . "\n"; + $output .= "ticket/" . $id . "\n"; } elsif ($format eq "s") { - $output .= $ticket->Id . ": ". $ticket->Subject . "\n"; + if ($fields) { + my $result = $m->comp("/REST/1.0/Forms/ticket/default", id => $id, format => $format, fields => \%fields); + my ($notes, $order, $key_values, $errors) = @$result; + # If it's the first time through, add our header + if ($n == 1) { + $output .= join("\t",@$order)."\n"; + } + # Cut off the annoying ticket/ before the id; + $key_values->{'id'} = $id; + $output .= join("\t", map {$key_values->{$_}} @$order)."\n"; + + + } else { + $output .= $ticket->Id . ": ". $ticket->Subject . "\n"; + } } else { - my $id = $ticket->Id; my $d = $m->comp("/REST/1.0/Forms/ticket/default", id => $id, format => $format, fields => \%fields); my ($c, $o, $k, $e) = @$d; push @output, [ $c, $o, $k ]; @@ -138,4 +154,5 @@ OUTPUT: $m->out("RT/". $RT::VERSION . " " . $status ."\n\n"); $m->out($output ); +return(); </%INIT> diff --git a/rt/html/REST/1.0/ticket/comment b/rt/html/REST/1.0/ticket/comment index e27bfcc1e..240dd90fb 100644 --- a/rt/html/REST/1.0/ticket/comment +++ b/rt/html/REST/1.0/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -60,7 +62,7 @@ my $status = "200 Ok"; my $output; my $action; -# http://.../REST/1.0/ticket/comment/1 +# http://.../REST/1.0/ticket/1/comment my ($c, $o, $k, $e) = @{ form_parse($content)->[0] }; if ($e || !$o) { if (!$o) { diff --git a/rt/html/REST/1.0/ticket/link b/rt/html/REST/1.0/ticket/link index 6556a5ef7..766e12624 100644 --- a/rt/html/REST/1.0/ticket/link +++ b/rt/html/REST/1.0/ticket/link @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -72,7 +74,7 @@ my %lfields = ( # http://.../REST/1.0/ticket/link/1 -$object =~ s#^/##; +$object =~ s#^/REST/1.0/ticket/link##; if ($id && $object && $id != $object) { $output = "Different ids in URL (`$object') and submitted form (`$id').\n"; $status = "400 Bad Request"; @@ -109,6 +111,9 @@ my $op = $del ? "DeleteLink" : "AddLink"; ($n, $output) = $ticket->$op(Type => $type, $mode => $to); if ($n == 0) { $status = "500 Error"; +} else { + my $action = $del ? "Deleted" : "Created"; + $output .= " $action link " . $ticket->Id . " $rel $to"; } OUTPUT: diff --git a/rt/html/REST/1.0/ticket/merge b/rt/html/REST/1.0/ticket/merge index 3db52111b..d6ae96f83 100644 --- a/rt/html/REST/1.0/ticket/merge +++ b/rt/html/REST/1.0/ticket/merge @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC %# <jesse@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -22,7 +22,9 @@ %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software -%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: |