X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fhtml%2FREST%2F1.0%2Fsearch%2Fticket;h=bd3d63fe73058929b9883f352af6e35007337047;hp=6b52ac8b8ab7115e78fe9b9e4885108b5b2c8a71;hb=fc6209f398899f0211cfcedeb81a3cd65e04a941;hpb=d39d52aac8f38ea9115628039f0df5aa3ac826de diff --git a/rt/html/REST/1.0/search/ticket b/rt/html/REST/1.0/search/ticket index 6b52ac8b8..bd3d63fe7 100644 --- a/rt/html/REST/1.0/search/ticket +++ b/rt/html/REST/1.0/search/ticket @@ -1,8 +1,8 @@ -%# {{{ BEGIN BPS TAGGED BLOCK +%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC %# %# %# (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/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: @@ -42,7 +44,7 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# }}} END BPS TAGGED BLOCK +%# END BPS TAGGED BLOCK }}} %# REST/1.0/search/ticket %# <%ARGS> @@ -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,15 +117,29 @@ 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("$RT::WebPath/REST/1.0/Forms/ticket/default", id => $id, format => $format, fields => \%fields); + 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 ]; } @@ -135,7 +151,8 @@ if ($n == 0 && $format ne "i") { $output = form_compose(\@output) if @output; OUTPUT: -$m->out("RT/". $RT::VERSION . " " . $status); +$m->out("RT/". $RT::VERSION . " " . $status ."\n\n"); $m->out($output ); +return();