9 Abort('No ticket specified');
12 if ($ARGS{'id'} eq 'new') {
13 # {{{ Create a new ticket
15 my $Queue = new RT::Queue( $session{'CurrentUser'} );
16 $Queue->Load($ARGS{'Queue'});
17 unless ( $Queue->id ) {
18 Abort('Queue not found');
21 unless ( $Queue->CurrentUserHasRight('CreateTicket') ) {
22 Abort('You have no permission to create tickets in that queue.');
25 ($Ticket, @Actions) = CreateTicket(
26 Attachments => delete $session{'Attachments'},
29 unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
30 Abort("No permission to view newly created ticket #".$Ticket->id.".");
34 $Ticket ||= LoadTicket($ARGS{'id'});
36 $m->callback( CallbackName => 'BeforeProcessArguments',
38 ActionsRef => \@Actions, ARGSRef => \%ARGS );
39 if ( defined $ARGS{'Action'} ) {
40 if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
42 my ($res, $msg) = $Ticket->$action();
47 $m->callback(CallbackName => 'ProcessArguments',
50 Actions => \@Actions);
52 $ARGS{UpdateAttachments} = $session{'Attachments'};
59 delete $session{'Attachments'};
61 #Process status updates
62 push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
63 push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $Ticket );
64 push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $Ticket );
65 push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $Ticket );
66 push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket );
68 # XXX: we shouldn't block actions here if user has no right to see the ticket,
69 # but we should allow him to see actions he has done
70 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
71 Abort("No permission to view ticket");
73 if ( $ARGS{'MarkAsSeen'} ) {
74 $Ticket->SetAttribute(
75 Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo',
76 Content => $Ticket->LastUpdated,
78 push @Actions, loc('Marked all messages as seen');
83 CallbackName => 'BeforeDisplay',
84 TicketObj => \$Ticket,
89 # This code does automatic redirection if any updates happen.
93 # We've done something, so we need to clear the decks to avoid
94 # resubmission on refresh.
95 # But we need to store Actions somewhere too, so we don't lose them.
96 my $key = Digest::MD5::md5_hex( rand(1024) );
97 push @{ $session{"Actions"}->{$key} ||= [] }, @Actions;
99 my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key;
100 $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor};
101 RT::Interface::Web::Redirect($url);
104 # If we haven't been passed in an Attachments object (through the precaching mechanism)
105 # then we need to find one
106 my $Attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
109 while ( my $attach = $Attachments->Next() ) {
110 next unless ($attach->Filename());
111 unshift( @{ $documents{ $attach->Filename } }, $attach );
114 my $Customers = $Ticket->Customers;
116 while ( my $customer = $Customers->Next() ) {
117 push @customers, $customer;
120 my $CustomFields = $Ticket->CustomFields;
122 CallbackName => 'MassageCustomFields',
124 CustomFields => $CustomFields,
127 my $print_value = sub {
128 my ($cf, $value) = @_;
129 my $linked = $value->LinkValueTo;
130 if ( defined $linked && length $linked ) {
131 my $linked = $m->interp->apply_escapes( $linked, 'h' );
132 $m->out('<a href="'. $linked .'" target="_new">');
134 my $comp = "ShowCustomField". $cf->Type;
136 CallbackName => 'ShowComponentName',
141 if ( $m->comp_exists( $comp ) ) {
142 $m->comp( $comp, Object => $value );
144 $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
146 $m->out('</a>') if defined $linked && length $linked;
148 # This section automatically populates a div with the "IncludeContentForValue" for this custom
149 # field if it's been defined
150 if ( $cf->IncludeContentForValue ) {
151 my $vid = $value->id;
152 $m->out( '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' );
153 $m->print( loc("See also:") );
154 $m->out( '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' );
155 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') );
156 $m->out( qq{</a></div>\n} );
157 $m->out( qq{<script><!--\njQuery('#object_cf_value_$vid').load(} );
158 $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'j') );
159 $m->out( qq{);\n--></script>\n} );
164 <&| /m/_elements/wrapper, title => $Ticket->Subject &>
165 <div id="ticket-show">
166 <& /m/_elements/ticket_menu, ticket => $Ticket &>
168 <&| /Widgets/TitleBox, title => loc('The Basics'),
169 class => 'ticket-info-basics',
174 <div class="label id"><&|/l&>Id</&>:</div>
175 <div class="value id"><%$Ticket->Id %></div>
178 <div class="label status"><&|/l&>Status</&>:</div>
179 <div class="value status"><% loc($Ticket->Status) %></div>
181 % if ($Ticket->TimeEstimated) {
183 <div class="label time estimated"><&|/l&>Estimated</&>:</div>
184 <div class="value time estimated"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div>
187 % if ($Ticket->TimeWorked) {
189 <div class="label time worked"><&|/l&>Worked</&>:</div>
190 <div class="value time worked"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &></div>
193 % if ($Ticket->TimeLeft) {
195 <div class="label time left"><&|/l&>Left</&>:</div>
196 <div class="value time left"><& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &></div>
200 <div class="label priority"><&|/l&>Priority</&>:</div>
201 <div class="value priority"><& /Ticket/Elements/ShowPriority, Ticket => $Ticket &></div>
204 <div class="label queue"><&|/l&>Queue</&>:</div>
205 <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div>
209 % if ($Ticket->CustomFields->First) {
210 <&| /Widgets/TitleBox, title => loc('Custom Fields'),
211 class => 'ticket-info-cfs',
214 % while ( my $CustomField = $CustomFields->Next ) {
215 % my $Values = $Ticket->CustomFieldValues( $CustomField->Id );
216 % my $count = $Values->Count;
217 <div class="entry" id="CF-<%$CustomField->id%>-ShowRow">
218 <div class="label"><% $CustomField->Name %>:</div>
220 % unless ( $count ) {
221 <i><&|/l&>(no value)</&></i>
222 % } elsif ( $count == 1 ) {
223 % $print_value->( $CustomField, $Values->First );
226 % while ( my $Value = $Values->Next ) {
228 % $print_value->( $CustomField, $Value );
240 <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &>
244 <div class="label"><&|/l&>Owner</&>:</div>
245 <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket &>
249 <div class="label"><&|/l&>Requestors</&>:</div>
250 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket &></div>
253 <div class="label"><&|/l&>Cc</&>:</div>
254 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket &></div>
257 <div class="label"><&|/l&>AdminCc</&>:</div>
258 <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket &></div>
263 % if (keys %documents) {
264 <&| /Widgets/TitleBox, title => loc('Attachments'),
265 title_class=> 'inverse',
266 class => 'ticket-info-attachments',
267 color => "#336699" &>
269 % foreach my $key (keys %documents) {
273 % foreach my $rev (@{$documents{$key}}) {
276 my $size = $rev->ContentLength;
279 my $kb = int($size/102.4) / 10;
280 my $units = RT->Config->Get('AttachmentUnits');
282 if (!defined($units)) {
290 elsif ($units eq 'k') {
300 <a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | u%>">
301 <&|/l, $rev->CreatedAsString, $size, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
312 % # too painful to deal with reminders
313 % if ( 0 && RT->Config->Get('EnableReminders') ) {
314 <&|/Widgets/TitleBox, title => loc("Reminders"),
315 class => 'ticket-info-reminders',
317 <div class="entry"><div
318 <form action="<%RT->Config->Get('WebPath')%>/Ticket/Display.html" method="post">
319 <& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &>
320 <div align="right"><input type="submit" class="button" value="<&|/l&>Save</&>" /></div>
326 % if ( @customers ) {
327 <&| /Widgets/TitleBox, title => loc("Customers"),
328 class => 'ticket-info-customers',
330 % foreach my $customer ( @customers ) {
331 % my $resolver = $customer->TargetURI->Resolver or next;
332 <div class="entry"><a href="<% $resolver->HREF %>"><% $resolver->AsString |n%></A>
339 <&| /Widgets/TitleBox, title => loc("Dates"),
340 class => 'ticket-info-dates',
345 <div class="label date created"><&|/l&>Created</&>:</div>
346 <div class="value date created"><% $Ticket->CreatedObj->AsString %></div>
349 <div class="label date starts"><&|/l&>Starts</&>:</div>
350 <div class="value date starts"><% $Ticket->StartsObj->AsString %></div>
353 <div class="label date started"><&|/l&>Started</&>:</div>
354 <div class="value date started"><% $Ticket->StartedObj->AsString %></div>
357 <div class="label date told"><&|/l&>Last Contact</&>:</div>
358 <div class="value date told"><% $Ticket->ToldObj->AsString %></div>
361 <div class="label date due"><&|/l&>Due</&>:</div>
362 % my $due = $Ticket->DueObj;
363 % if ( $due && $due->Unix > 0 && $due->Diff < 0 ) {
364 <div class="value date due"><span class="overdue"><% $due->AsString %></span></div>
366 <div class="value date due"><% $due->AsString %></div>
370 <div class="label date resolved"><&|/l&>Closed</&>:</div>
371 <div class="value date resolved"><% $Ticket->ResolvedObj->AsString %></div>
374 <div class="label date updated"><&|/l&>Updated</&>:</div>
375 % my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never");
376 <div class="value date updated"><% $UpdatedString | h %></div>
381 <&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &>
384 <div class="label"><% loc('Depends on')%>:</div>
388 my ( @active, @inactive, @not_tickets );
389 for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
390 my $target = $link->TargetObj;
391 if ( $target && $target->isa('RT::Ticket') ) {
392 if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) {
393 push( @inactive, $link->TargetURI );
396 push( @active, $link->TargetURI );
400 push( @not_tickets, $link->TargetURI );
407 % for my $Link (@not_tickets, @active, @inactive) {
408 <li><& /Elements/ShowLink, URI => $Link &></li>
414 <div class="label"><% loc('Depended on by')%>:</div>
417 % while (my $Link = $Ticket->DependedOnBy->Next) {
418 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
424 <div class="label"><% loc('Parents') %>:</div>
425 <div class="value"><& /Ticket/Elements/ShowParents, Ticket => $Ticket &></div>
428 <div class="label"><% loc('Children')%>:</div>
429 <div class="value"><& /Ticket/Elements/ShowMembers, Ticket => $Ticket &></div>
432 <div class="label"><% loc('Refers to')%>:</div>
435 % while (my $Link = $Ticket->RefersTo->Next) {
436 <li><& /Elements/ShowLink, URI => $Link->TargetURI &></li>
442 <div class="label"><% loc('Referred to by')%>:</div>
445 % while (my $Link = $Ticket->ReferredToBy->Next) {
446 % next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket') && $Link->BaseObj->Type eq 'reminder');
447 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>