1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
6 %# <sales@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., 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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
56 Abort('No ticket specified');
59 if ($ARGS{'id'} eq 'new') {
60 # {{{ Create a new ticket
62 my $Queue = RT::Queue->new( $session{'CurrentUser'} );
63 $Queue->Load($ARGS{'Queue'});
64 unless ( $Queue->id ) {
65 Abort('Queue not found');
68 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
69 Abort('You have no permission to create tickets in that queue.');
72 ($Ticket, @Actions) = CreateTicket(
73 Attachments => delete $session{'Attachments'},
76 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
77 Abort("No permission to view newly created ticket #".$Ticket->id.".");
80 $Ticket ||= LoadTicket($ARGS{'id'});
82 $m->callback( CallbackName => 'BeforeProcessArguments',
84 ActionsRef => \@Actions, ARGSRef => \%ARGS );
85 if ( defined $ARGS{'Action'} ) {
86 if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
88 my ($res, $msg) = $Ticket->$action();
93 $m->callback(CallbackName => 'ProcessArguments',
96 Actions => \@Actions);
98 $ARGS{UpdateAttachments} = $session{'Attachments'};
100 ProcessUpdateMessage(
102 Actions => \@Actions,
103 TicketObj => $Ticket,
105 delete $session{'Attachments'};
107 #Process status updates
108 push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
109 push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $Ticket );
110 push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $Ticket );
111 push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $Ticket );
112 push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket );
113 push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket );
115 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
117 Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
119 Abort("No permission to view ticket");
122 if ( $ARGS{'MarkAsSeen'} ) {
123 $Ticket->SetAttribute(
124 Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
125 Content => $Ticket->LastUpdated,
127 push @Actions, loc('Marked all messages as seen');
132 CallbackName => 'BeforeDisplay',
133 TicketObj => \$Ticket,
134 Actions => \@Actions,
138 # This code does automatic redirection if any updates happen.
142 # We've done something, so we need to clear the decks to avoid
143 # resubmission on refresh.
144 # But we need to store Actions somewhere too, so we don't lose them.
145 my $key = Digest::MD5::md5_hex( rand(1024) );
146 push @{ $session{"Actions"}->{$key} ||= [] }, @Actions;
148 my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key;
149 $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor};
150 RT::Interface::Web::Redirect($url);
153 # If we haven't been passed in an Attachments object (through the precaching mechanism)
154 # then we need to find one
155 my $Attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
158 while ( my $attach = $Attachments->Next() ) {
159 next unless ($attach->Filename());
160 unshift( @{ $documents{ $attach->Filename } }, $attach );
163 my $CustomFields = $Ticket->CustomFields;
165 CallbackName => 'MassageCustomFields',
167 CustomFields => $CustomFields,
170 my $print_value = sub {
171 my ($cf, $value) = @_;
172 my $linked = $value->LinkValueTo;
173 if ( defined $linked && length $linked ) {
174 my $linked = $m->interp->apply_escapes( $linked, 'h' );
175 $m->out('<a href="'. $linked .'" target="_new">');
177 my $comp = "ShowCustomField". $cf->Type;
179 CallbackName => 'ShowComponentName',
184 if ( $m->comp_exists( $comp ) ) {
185 $m->comp( $comp, Object => $value );
187 $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
189 $m->out('</a>') if defined $linked && length $linked;
191 # This section automatically populates a div with the "IncludeContentForValue" for this custom
192 # field if it's been defined
193 if ( $cf->IncludeContentForValue ) {
194 my $vid = $value->id;
195 $m->out( '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' );
196 $m->print( loc("See also:") );
197 $m->out( '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' );
198 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') );
199 $m->out( qq{</a></div>\n} );
200 $m->out( qq{<script><!--\njQuery('#object_cf_value_$vid').load(} );
201 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'j') );
202 $m->out( qq{);\n--></script>\n} );
207 <&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &>
208 <div id="ticket-show">
209 <& /m/_elements/ticket_menu, ticket => $Ticket &>
211 <&| /Widgets/TitleBox, title => loc('The Basics'),
212 class => 'ticket-info-basics',
217 <div class="label id"><&|/l&>Id</&>:</div>
218 <div class="value id"><%$Ticket->Id %></div>
221 <div class="label status"><&|/l&>Status</&>:</div>
222 <div class="value status"><% loc($Ticket->Status) %></div>
224 % if ($Ticket->TimeEstimated) {
226 <div class="label time estimated"><&|/l&>Estimated</&>:</div>
227 <div class="value time estimated"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div>
230 % if ($Ticket->TimeWorked) {
232 <div class="label time worked"><&|/l&>Worked</&>:</div>
233 <div class="value time worked"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &></div>
236 % if ($Ticket->TimeLeft) {
238 <div class="label time left"><&|/l&>Left</&>:</div>
239 <div class="value time left"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &></div>
243 <div class="label priority"><&|/l&>Priority</&>:</div>
244 <div class="value priority"><& /Ticket/Elements/ShowPriority, Ticket => $Ticket &></div>
247 <div class="label queue"><&|/l&>Queue</&>:</div>
248 <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div>
251 <div class="label bookmark"><&|/l&>Bookmark</&>:</div>
252 <div class="value bookmark"><& /Ticket/Elements/Bookmark, id => $Ticket->id &></div>
256 % if ($Ticket->CustomFields->First) {
257 <&| /Widgets/TitleBox, title => loc('Custom Fields'),
258 class => 'ticket-info-cfs',
261 % while ( my $CustomField = $CustomFields->Next ) {
262 % my $Values = $Ticket->CustomFieldValues( $CustomField->Id );
263 % my $count = $Values->Count;
264 <div class="entry" id="CF-<%$CustomField->id%>-ShowRow">
265 <div class="label"><% $CustomField->Name %>:</div>
267 % unless ( $count ) {
268 <i><&|/l&>(no value)</&></i>
269 % } elsif ( $count == 1 ) {
270 % $print_value->( $CustomField, $Values->First );
273 % while ( my $Value = $Values->Next ) {
275 % $print_value->( $CustomField, $Value );
287 <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &>
291 <div class="label"><&|/l&>Owner</&>:</div>
292 <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket &>
296 <div class="label"><&|/l&>Requestors</&>:</div>
297 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket &></div>
300 <div class="label"><&|/l&>Cc</&>:</div>
301 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket &></div>
304 <div class="label"><&|/l&>AdminCc</&>:</div>
305 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket &></div>
310 % if (keys %documents) {
311 <&| /Widgets/TitleBox, title => loc('Attachments'),
312 title_class=> 'inverse',
313 class => 'ticket-info-attachments',
314 color => "#336699" &>
316 % foreach my $key (keys %documents) {
320 % foreach my $rev (@{$documents{$key}}) {
323 my $size = $rev->ContentLength;
326 my $kb = int($size/102.4) / 10;
327 my $units = RT->Config->Get('AttachmentUnits');
329 if (!defined($units)) {
337 elsif ($units eq 'k') {
347 <a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | un%>">
348 <&|/l, $rev->CreatedAsString, $size, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
359 % # too painful to deal with reminders
360 % if ( 0 && RT->Config->Get('EnableReminders') ) {
361 <&|/Widgets/TitleBox, title => loc("Reminders"),
362 class => 'ticket-info-reminders',
364 <div class="entry"><div
365 <form action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
366 <& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &>
367 <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
373 <&| /Widgets/TitleBox, title => loc("Dates"),
374 class => 'ticket-info-dates',
379 <div class="label date created"><&|/l&>Created</&>:</div>
380 <div class="value date created"><% $Ticket->CreatedObj->AsString %></div>
383 <div class="label date starts"><&|/l&>Starts</&>:</div>
384 <div class="value date starts"><% $Ticket->StartsObj->AsString %></div>
387 <div class="label date started"><&|/l&>Started</&>:</div>
388 <div class="value date started"><% $Ticket->StartedObj->AsString %></div>
391 <div class="label date told"><&|/l&>Last Contact</&>:</div>
392 <div class="value date told"><% $Ticket->ToldObj->AsString %></div>
395 <div class="label date due"><&|/l&>Due</&>:</div>
396 % my $due = $Ticket->DueObj;
397 % if ( $due && $due->Unix > 0 && $due->Diff < 0 ) {
398 <div class="value date due"><span class="overdue"><% $due->AsString %></span></div>
400 <div class="value date due"><% $due->AsString %></div>
404 <div class="label date resolved"><&|/l&>Closed</&>:</div>
405 <div class="value date resolved"><% $Ticket->ResolvedObj->AsString %></div>
408 <div class="label date updated"><&|/l&>Updated</&>:</div>
409 % my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never");
410 <div class="value date updated"><% $UpdatedString | h %></div>
415 <&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &>
418 <div class="label"><% loc('Depends on')%>:</div>
422 my ( @active, @inactive, @not_tickets );
423 for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
424 my $target = $link->TargetObj;
425 if ( $target && $target->isa('RT::Ticket') ) {
426 if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) {
427 push( @inactive, $link->TargetURI );
430 push( @active, $link->TargetURI );
434 push( @not_tickets, $link->TargetURI );
441 % for my $Link (@not_tickets, @active, @inactive) {
442 <li><& /Elements/ShowLink, URI => $Link &></li>
448 <div class="label"><% loc('Depended on by')%>:</div>
451 % while (my $Link = $Ticket->DependedOnBy->Next) {
452 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
458 <div class="label"><% loc('Parents') %>:</div>
459 <div class="value"><& /Ticket/Elements/ShowParents, Ticket => $Ticket &></div>
462 <div class="label"><% loc('Children')%>:</div>
463 <div class="value"><& /Ticket/Elements/ShowMembers, Ticket => $Ticket &></div>
466 <div class="label"><% loc('Refers to')%>:</div>
469 % while (my $Link = $Ticket->RefersTo->Next) {
470 <li><& /Elements/ShowLink, URI => $Link->TargetURI &></li>
476 <div class="label"><% loc('Referred to by')%>:</div>
479 % while (my $Link = $Ticket->ReferredToBy->Next) {
480 % next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket') && $Link->BaseObj->Type eq 'reminder');
481 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>