1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 %# CONTRIBUTION SUBMISSION POLICY:
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
45 %# END BPS TAGGED BLOCK }}}
46 %# REST/1.0/Forms/ticket/history
55 my $ticket = new RT::Ticket $session{CurrentUser};
56 my ($c, $o, $k, $e) = ("", [], {}, "");
59 unless ($ticket->Id) {
60 return [ "# Ticket $id does not exist.", [], {}, 1 ];
63 my $trans = $ticket->Transactions();
64 my $total = $trans->Count();
67 my @arglist = split('/', $args);
70 if ($arglist[0] eq 'type') {
72 } elsif ($arglist[0] eq 'id') {
79 # Create, Set, Status, Correspond, Comment, Give, Steal, Take, Told
80 # CustomField, AddLink, DeleteLink, AddWatcher, DelWatcher
81 if ($args =~ /^links?$/) {
82 $trans->Limit(FIELD => 'Type', OPERATOR => 'LIKE', VALUE => '%Link');
84 elsif ($args =~ /^watchers?$/) {
85 $trans->Limit(FIELD => 'Type', OPERATOR => 'LIKE', VALUE => '%Watcher');
88 $trans->Limit(FIELD => 'Type', OPERATOR => '=', VALUE => $type);
91 $trans->Limit(FIELD => 'Id', OPERATOR => '=', VALUE => $tid);
96 my $t = new RT::Transaction $session{CurrentUser};
99 push @data, [ id => $t->Id ];
100 push @data, [ Ticket => $t->Ticket ]
101 if (!%$fields || exists $fields->{lc 'Ticket'});
102 push @data, [ TimeTaken => $t->TimeTaken ]
103 if (!%$fields || exists $fields->{lc 'TimeTaken'});
104 push @data, [ Type => $t->Type ]
105 if (!%$fields || exists $fields->{lc 'Type'});
106 push @data, [ Field => $t->Field ]
107 if (!%$fields || exists $fields->{lc 'Field'});
108 push @data, [ OldValue => $t->OldValue ]
109 if (!%$fields || exists $fields->{lc 'OldValue'});
110 push @data, [ NewValue => $t->NewValue ]
111 if (!%$fields || exists $fields->{lc 'NewValue'});
112 push @data, [ Data => $t->Data ]
113 if (!%$fields || exists $fields->{lc 'Data'});
114 push @data, [ Description => $t->Description ]
115 if (!%$fields || exists $fields->{lc 'Description'});
116 push @data, [ Content => $t->Content ]
117 if (!%$fields || exists $fields->{lc 'Content'});
120 if (!%$fields || exists $fields->{lc 'Content'}) {
121 my $creator = new RT::User $session{CurrentUser};
122 $creator->Load($t->Creator);
123 push @data, [ Creator => $creator->Name ];
125 push @data, [ Created => $t->Created ]
126 if (!%$fields || exists $fields->{lc 'Created'});
128 if (!%$fields || exists $fields->{lc 'Attachments'}) {
130 my $attachments = $t->Attachments;
131 while (my $a = $attachments->Next) {
132 my $size = length($a->Content);
133 if ($size > 1024) { $size = int($size/102.4)/10 . "k" }
134 else { $size .= "b" }
135 $attachlist .= "\n" . $a->Id.": ".($a->Filename || "untitled")." (".$size.")";
138 push @data, [Attachments => $attachlist];
141 my %k = map {@$_} @data;
142 $o = [ map {$_->[0]} @data ];
148 $format = "l" if (%$fields);
150 while (my $t = $trans->Next) {
153 if ($format eq "l") {
154 $tids .= "," if $tids;
158 $k->{$tid} = $t->Description;
162 if ($format eq "l") {
164 push @tid, "ticket/$id/history/id/$tids";
166 foreach my $key (keys %$fields) {
167 $fieldstring .= "," if $fieldstring;
168 $fieldstring .= $key;
170 my ($content, $forms);
172 $m->subexec("$RT::WebPath/REST/1.0/show",
175 fields => $fieldstring);
176 return [ $c, $o, $k, $e ];
181 my $sub = $trans->Count();
182 $c = "# $sub/$total ($args/total)";
185 return [ $c, $o, $k, $e ];