]>
Commit | Line | Data |
---|---|---|
84fb5b46 MKG |
1 | %# BEGIN BPS TAGGED BLOCK {{{ |
2 | %# | |
3 | %# COPYRIGHT: | |
4 | %# | |
320f0092 | 5 | %# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC |
84fb5b46 MKG |
6 | %# <sales@bestpractical.com> |
7 | %# | |
8 | %# (Except where explicitly superseded by other copyright notices) | |
9 | %# | |
10 | %# | |
11 | %# LICENSE: | |
12 | %# | |
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 | |
16 | %# from www.gnu.org. | |
17 | %# | |
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. | |
22 | %# | |
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., 51 Franklin Street, Fifth Floor, Boston, MA | |
26 | %# 02110-1301 or visit their web page on the internet at | |
27 | %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. | |
28 | %# | |
29 | %# | |
30 | %# CONTRIBUTION SUBMISSION POLICY: | |
31 | %# | |
32 | %# (The following paragraph is not intended to limit the rights granted | |
33 | %# to you to modify and distribute this software under the terms of | |
34 | %# the GNU General Public License and is only of importance to you if | |
35 | %# you choose to contribute your changes and enhancements to the | |
36 | %# community by submitting them to Best Practical Solutions, LLC.) | |
37 | %# | |
38 | %# By intentionally submitting any modifications, corrections or | |
39 | %# derivatives to this work, or any other work intended for use with | |
40 | %# Request Tracker, to Best Practical Solutions, LLC, you confirm that | |
41 | %# you are the copyright holder for those contributions and you grant | |
42 | %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, | |
43 | %# royalty-free, perpetual, license to use, copy, create derivative | |
44 | %# works based on those contributions, and sublicense and distribute | |
45 | %# those contributions and any derivatives thereof. | |
46 | %# | |
47 | %# END BPS TAGGED BLOCK }}} | |
48 | <%args> | |
49 | $id => undef | |
50 | </%args> | |
51 | <%init> | |
52 | my $Ticket; | |
53 | my @Actions; | |
54 | ||
55 | unless ($id) { | |
56 | Abort('No ticket specified'); | |
57 | } | |
58 | ||
59 | if ($ARGS{'id'} eq 'new') { | |
60 | # {{{ Create a new ticket | |
61 | ||
62 | my $Queue = RT::Queue->new( $session{'CurrentUser'} ); | |
63 | $Queue->Load($ARGS{'Queue'}); | |
64 | unless ( $Queue->id ) { | |
65 | Abort('Queue not found'); | |
66 | } | |
67 | ||
68 | unless ( $Queue->CurrentUserHasRight('CreateTicket') ) { | |
69 | Abort('You have no permission to create tickets in that queue.'); | |
70 | } | |
71 | ||
af59614d | 72 | ($Ticket, @Actions) = CreateTicket( %ARGS ); |
84fb5b46 MKG |
73 | unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) { |
74 | Abort("No permission to view newly created ticket #".$Ticket->id."."); | |
75 | } | |
76 | } else { | |
77 | $Ticket ||= LoadTicket($ARGS{'id'}); | |
78 | ||
79 | $m->callback( CallbackName => 'BeforeProcessArguments', | |
80 | TicketObj => $Ticket, | |
81 | ActionsRef => \@Actions, ARGSRef => \%ARGS ); | |
82 | if ( defined $ARGS{'Action'} ) { | |
83 | if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) { | |
84 | my $action = $1; | |
85 | my ($res, $msg) = $Ticket->$action(); | |
86 | push(@Actions, $msg); | |
87 | } | |
88 | } | |
89 | ||
90 | $m->callback(CallbackName => 'ProcessArguments', | |
91 | Ticket => $Ticket, | |
92 | ARGSRef => \%ARGS, | |
93 | Actions => \@Actions); | |
94 | ||
84fb5b46 MKG |
95 | push @Actions, |
96 | ProcessUpdateMessage( | |
97 | ARGSRef => \%ARGS, | |
98 | Actions => \@Actions, | |
99 | TicketObj => $Ticket, | |
100 | ); | |
84fb5b46 MKG |
101 | |
102 | #Process status updates | |
103 | push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket ); | |
104 | push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $Ticket ); | |
105 | push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $Ticket ); | |
106 | push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $Ticket ); | |
107 | push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket ); | |
108 | push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket ); | |
109 | ||
84fb5b46 | 110 | unless ($Ticket->CurrentUserHasRight('ShowTicket')) { |
403d7b0b MKG |
111 | if (@Actions) { |
112 | Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions); | |
113 | } else { | |
114 | Abort("No permission to view ticket"); | |
115 | } | |
84fb5b46 MKG |
116 | } |
117 | if ( $ARGS{'MarkAsSeen'} ) { | |
118 | $Ticket->SetAttribute( | |
119 | Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo', | |
120 | Content => $Ticket->LastUpdated, | |
121 | ); | |
122 | push @Actions, loc('Marked all messages as seen'); | |
123 | } | |
124 | } | |
125 | ||
126 | $m->callback( | |
127 | CallbackName => 'BeforeDisplay', | |
128 | TicketObj => \$Ticket, | |
129 | Actions => \@Actions, | |
130 | ARGSRef => \%ARGS, | |
131 | ); | |
132 | ||
133 | # This code does automatic redirection if any updates happen. | |
134 | ||
135 | if (@Actions) { | |
136 | ||
137 | # We've done something, so we need to clear the decks to avoid | |
138 | # resubmission on refresh. | |
139 | # But we need to store Actions somewhere too, so we don't lose them. | |
140 | my $key = Digest::MD5::md5_hex( rand(1024) ); | |
141 | push @{ $session{"Actions"}->{$key} ||= [] }, @Actions; | |
142 | $session{'i'}++; | |
143 | my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key; | |
144 | $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor}; | |
145 | RT::Interface::Web::Redirect($url); | |
146 | } | |
147 | ||
148 | # If we haven't been passed in an Attachments object (through the precaching mechanism) | |
149 | # then we need to find one | |
af59614d | 150 | my $Attachments = $Ticket->Attachments; |
84fb5b46 MKG |
151 | |
152 | my %documents; | |
153 | while ( my $attach = $Attachments->Next() ) { | |
154 | next unless ($attach->Filename()); | |
155 | unshift( @{ $documents{ $attach->Filename } }, $attach ); | |
156 | } | |
157 | ||
158 | my $CustomFields = $Ticket->CustomFields; | |
159 | $m->callback( | |
160 | CallbackName => 'MassageCustomFields', | |
161 | Object => $Ticket, | |
162 | CustomFields => $CustomFields, | |
163 | ); | |
164 | ||
165 | my $print_value = sub { | |
166 | my ($cf, $value) = @_; | |
167 | my $linked = $value->LinkValueTo; | |
168 | if ( defined $linked && length $linked ) { | |
169 | my $linked = $m->interp->apply_escapes( $linked, 'h' ); | |
170 | $m->out('<a href="'. $linked .'" target="_new">'); | |
171 | } | |
172 | my $comp = "ShowCustomField". $cf->Type; | |
173 | $m->callback( | |
174 | CallbackName => 'ShowComponentName', | |
175 | Name => \$comp, | |
176 | CustomField => $cf, | |
177 | Object => $Ticket, | |
178 | ); | |
179 | if ( $m->comp_exists( $comp ) ) { | |
180 | $m->comp( $comp, Object => $value ); | |
181 | } else { | |
182 | $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) ); | |
183 | } | |
184 | $m->out('</a>') if defined $linked && length $linked; | |
185 | ||
186 | # This section automatically populates a div with the "IncludeContentForValue" for this custom | |
187 | # field if it's been defined | |
188 | if ( $cf->IncludeContentForValue ) { | |
189 | my $vid = $value->id; | |
190 | $m->out( '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' ); | |
191 | $m->print( loc("See also:") ); | |
192 | $m->out( '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' ); | |
193 | $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') ); | |
194 | $m->out( qq{</a></div>\n} ); | |
195 | $m->out( qq{<script><!--\njQuery('#object_cf_value_$vid').load(} ); | |
196 | $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'j') ); | |
197 | $m->out( qq{);\n--></script>\n} ); | |
198 | } | |
199 | }; | |
200 | ||
201 | </%init> | |
202 | <&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &> | |
203 | <div id="ticket-show"> | |
204 | <& /m/_elements/ticket_menu, ticket => $Ticket &> | |
205 | ||
206 | <&| /Widgets/TitleBox, title => loc('The Basics'), | |
207 | class => 'ticket-info-basics', | |
208 | &> | |
209 | ||
210 | ||
211 | <div class="entry"> | |
212 | <div class="label id"><&|/l&>Id</&>:</div> | |
213 | <div class="value id"><%$Ticket->Id %></div> | |
214 | </div> | |
215 | <div class="entry"> | |
216 | <div class="label status"><&|/l&>Status</&>:</div> | |
217 | <div class="value status"><% loc($Ticket->Status) %></div> | |
218 | </div> | |
219 | % if ($Ticket->TimeEstimated) { | |
220 | <div class="entry"> | |
221 | <div class="label time estimated"><&|/l&>Estimated</&>:</div> | |
222 | <div class="value time estimated"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div> | |
223 | </div> | |
224 | % } | |
225 | % if ($Ticket->TimeWorked) { | |
226 | <div class="entry"> | |
227 | <div class="label time worked"><&|/l&>Worked</&>:</div> | |
228 | <div class="value time worked"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &></div> | |
229 | </div> | |
230 | % } | |
231 | % if ($Ticket->TimeLeft) { | |
232 | <div class="entry"> | |
233 | <div class="label time left"><&|/l&>Left</&>:</div> | |
234 | <div class="value time left"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &></div> | |
235 | </div> | |
236 | % } | |
237 | <div class="entry"> | |
238 | <div class="label priority"><&|/l&>Priority</&>:</div> | |
239 | <div class="value priority"><& /Ticket/Elements/ShowPriority, Ticket => $Ticket &></div> | |
240 | </div> | |
241 | <div class="entry"> | |
242 | <div class="label queue"><&|/l&>Queue</&>:</div> | |
243 | <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div> | |
403d7b0b MKG |
244 | </div> |
245 | <div class="entry"> | |
246 | <div class="label bookmark"><&|/l&>Bookmark</&>:</div> | |
247 | <div class="value bookmark"><& /Ticket/Elements/Bookmark, id => $Ticket->id &></div> | |
84fb5b46 MKG |
248 | </div> |
249 | </&> | |
250 | ||
251 | % if ($Ticket->CustomFields->First) { | |
252 | <&| /Widgets/TitleBox, title => loc('Custom Fields'), | |
253 | class => 'ticket-info-cfs', | |
254 | &> | |
255 | ||
256 | % while ( my $CustomField = $CustomFields->Next ) { | |
257 | % my $Values = $Ticket->CustomFieldValues( $CustomField->Id ); | |
258 | % my $count = $Values->Count; | |
259 | <div class="entry" id="CF-<%$CustomField->id%>-ShowRow"> | |
260 | <div class="label"><% $CustomField->Name %>:</div> | |
261 | <div class="value"> | |
262 | % unless ( $count ) { | |
263 | <i><&|/l&>(no value)</&></i> | |
264 | % } elsif ( $count == 1 ) { | |
265 | % $print_value->( $CustomField, $Values->First ); | |
266 | % } else { | |
267 | <ul> | |
268 | % while ( my $Value = $Values->Next ) { | |
269 | <li> | |
270 | % $print_value->( $CustomField, $Value ); | |
271 | </li> | |
272 | % } | |
273 | </ul> | |
274 | % } | |
275 | </div> | |
276 | </div> | |
277 | % } | |
278 | ||
279 | </&> | |
280 | % } | |
281 | ||
282 | <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &> | |
283 | ||
284 | ||
285 | <div class="entry"> | |
286 | <div class="label"><&|/l&>Owner</&>:</div> | |
c33a4027 | 287 | <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket, Link => 0 &> |
84fb5b46 MKG |
288 | </div> |
289 | </div> | |
290 | <div class="entry"> | |
291 | <div class="label"><&|/l&>Requestors</&>:</div> | |
c33a4027 | 292 | <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket, Link => 0 &></div> |
84fb5b46 MKG |
293 | </div> |
294 | <div class="entry"> | |
295 | <div class="label"><&|/l&>Cc</&>:</div> | |
c33a4027 | 296 | <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket, Link => 0 &></div> |
84fb5b46 MKG |
297 | </div> |
298 | <div class="entry"> | |
299 | <div class="label"><&|/l&>AdminCc</&>:</div> | |
c33a4027 | 300 | <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket, Link => 0 &></div> |
84fb5b46 MKG |
301 | </div> |
302 | ||
303 | </&> | |
304 | ||
305 | % if (keys %documents) { | |
306 | <&| /Widgets/TitleBox, title => loc('Attachments'), | |
307 | title_class=> 'inverse', | |
308 | class => 'ticket-info-attachments', | |
309 | color => "#336699" &> | |
310 | ||
311 | % foreach my $key (keys %documents) { | |
312 | ||
313 | <%$key%><br /> | |
314 | <ul> | |
315 | % foreach my $rev (@{$documents{$key}}) { | |
af59614d | 316 | % if ($rev->ContentLength) { |
84fb5b46 | 317 | <li><font size="-2"> |
af59614d MKG |
318 | <a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | un %>"> |
319 | <&|/l, $rev->CreatedAsString, $rev->FriendlyContentLength, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&> | |
84fb5b46 MKG |
320 | </a> |
321 | </font></li> | |
322 | % } | |
323 | % } | |
324 | </ul> | |
325 | ||
326 | % } | |
327 | </&> | |
328 | ||
329 | % } | |
330 | % # too painful to deal with reminders | |
331 | % if ( 0 && RT->Config->Get('EnableReminders') ) { | |
332 | <&|/Widgets/TitleBox, title => loc("Reminders"), | |
333 | class => 'ticket-info-reminders', | |
334 | &> | |
335 | <div class="entry"><div | |
336 | <form action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post"> | |
337 | <& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &> | |
338 | <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div> | |
339 | </form> | |
340 | </div></div> | |
341 | </&> | |
342 | % } | |
343 | ||
344 | <&| /Widgets/TitleBox, title => loc("Dates"), | |
345 | class => 'ticket-info-dates', | |
346 | &> | |
347 | ||
348 | ||
349 | <div class="entry"> | |
350 | <div class="label date created"><&|/l&>Created</&>:</div> | |
351 | <div class="value date created"><% $Ticket->CreatedObj->AsString %></div> | |
352 | </div> | |
353 | <div class="entry"> | |
354 | <div class="label date starts"><&|/l&>Starts</&>:</div> | |
355 | <div class="value date starts"><% $Ticket->StartsObj->AsString %></div> | |
356 | </div> | |
357 | <div class="entry"> | |
358 | <div class="label date started"><&|/l&>Started</&>:</div> | |
359 | <div class="value date started"><% $Ticket->StartedObj->AsString %></div> | |
360 | </div> | |
361 | <div class="entry"> | |
362 | <div class="label date told"><&|/l&>Last Contact</&>:</div> | |
363 | <div class="value date told"><% $Ticket->ToldObj->AsString %></div> | |
364 | </div> | |
365 | <div class="entry"> | |
366 | <div class="label date due"><&|/l&>Due</&>:</div> | |
367 | % my $due = $Ticket->DueObj; | |
c33a4027 | 368 | % if ( $due && $due->IsSet && $due->Diff < 0 && $Ticket->QueueObj->IsActiveStatus($Ticket->Status) ) { |
84fb5b46 MKG |
369 | <div class="value date due"><span class="overdue"><% $due->AsString %></span></div> |
370 | % } else { | |
371 | <div class="value date due"><% $due->AsString %></div> | |
372 | % } | |
373 | </div> | |
374 | <div class="entry"> | |
375 | <div class="label date resolved"><&|/l&>Closed</&>:</div> | |
376 | <div class="value date resolved"><% $Ticket->ResolvedObj->AsString %></div> | |
377 | </div> | |
378 | <div class="entry"> | |
379 | <div class="label date updated"><&|/l&>Updated</&>:</div> | |
380 | % my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never"); | |
381 | <div class="value date updated"><% $UpdatedString | h %></div> | |
382 | </div> | |
383 | ||
384 | </&> | |
385 | ||
386 | <&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &> | |
387 | ||
388 | <div class="entry"> | |
389 | <div class="label"><% loc('Depends on')%>:</div> | |
390 | <div class="value"> | |
391 | ||
392 | <%PERL> | |
393 | my ( @active, @inactive, @not_tickets ); | |
394 | for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) { | |
395 | my $target = $link->TargetObj; | |
396 | if ( $target && $target->isa('RT::Ticket') ) { | |
397 | if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) { | |
398 | push( @inactive, $link->TargetURI ); | |
399 | } | |
400 | else { | |
401 | push( @active, $link->TargetURI ); | |
402 | } | |
403 | } | |
404 | else { | |
405 | push( @not_tickets, $link->TargetURI ); | |
406 | } | |
407 | } | |
408 | </%PERL> | |
409 | ||
410 | ||
411 | <ul> | |
412 | % for my $Link (@not_tickets, @active, @inactive) { | |
413 | <li><& /Elements/ShowLink, URI => $Link &></li> | |
414 | % } | |
415 | </ul> | |
416 | </div> | |
417 | </div> | |
418 | <div class="entry"> | |
419 | <div class="label"><% loc('Depended on by')%>:</div> | |
420 | <div class="value"> | |
421 | <ul> | |
422 | % while (my $Link = $Ticket->DependedOnBy->Next) { | |
423 | <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li> | |
424 | % } | |
425 | </ul> | |
426 | </div> | |
427 | </div> | |
428 | <div class="entry"> | |
429 | <div class="label"><% loc('Parents') %>:</div> | |
af59614d | 430 | <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'MemberOf' &></div> |
84fb5b46 MKG |
431 | </div> |
432 | <div class="entry"> | |
433 | <div class="label"><% loc('Children')%>:</div> | |
af59614d | 434 | <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'Members' &></div> |
84fb5b46 MKG |
435 | </div> |
436 | <div class="entry"> | |
437 | <div class="label"><% loc('Refers to')%>:</div> | |
438 | <div class="value"> | |
439 | <ul> | |
440 | % while (my $Link = $Ticket->RefersTo->Next) { | |
441 | <li><& /Elements/ShowLink, URI => $Link->TargetURI &></li> | |
442 | % } | |
443 | </ul> | |
444 | </div> | |
445 | </div> | |
446 | <div class="entry"> | |
447 | <div class="label"><% loc('Referred to by')%>:</div> | |
448 | <div class="value"> | |
449 | <ul> | |
450 | % while (my $Link = $Ticket->ReferredToBy->Next) { | |
451 | % next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket') && $Link->BaseObj->Type eq 'reminder'); | |
452 | <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li> | |
453 | % } | |
454 | </ul> | |
455 | </div> | |
456 | </div> | |
457 | </&> | |
458 | </div> | |
459 | </&> |