[Rt-commit] r5379 - in rt/branches/3.7-EXPERIMENTAL: html/REST/1.0/search

ruz at bestpractical.com ruz at bestpractical.com
Thu Jun 15 18:03:14 EDT 2006


Author: ruz
Date: Thu Jun 15 18:03:12 2006
New Revision: 5379

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/REST/1.0/search/ticket

Log:
 r3121 at cubic-pc (orig r5298):  jesse | 2006-05-26 08:11:28 +0400
  r9831 at jesse-vincents-computer-2:  jesse | 2006-05-25 23:20:36 -0400
  * Added custom summary "ticket lists" using the commandline (combining -f and -s) lists.
  * Fixed a couple small bugs
 


Modified: rt/branches/3.7-EXPERIMENTAL/html/REST/1.0/search/ticket
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/REST/1.0/search/ticket	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/REST/1.0/search/ticket	Thu Jun 15 18:03:12 2006
@@ -60,7 +60,7 @@
 my $field  = '[a-zA-Z][a-zA-Z0-9_-]*';
 my (%fields, @fields);
 if ($fields) {
-    $format = "l";
+    $format ||= "l";
     unless ($fields =~ /^(?:$field,)*$field$/) {
         $status = "400 Bad Request";
         $output = "Invalid field specification: $fields";
@@ -115,15 +115,29 @@
 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 . "\t". $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 $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 +152,5 @@
 $m->out("RT/". $RT::VERSION . " " . $status ."\n\n");
 
 $m->out($output );
+return();
 </%INIT>


More information about the Rt-commit mailing list