%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <%args> $id => undef <%init> my $Ticket; my @Actions; unless ($id) { Abort('No ticket specified'); } if ($ARGS{'id'} eq 'new') { # {{{ Create a new ticket my $Queue = RT::Queue->new( $session{'CurrentUser'} ); $Queue->Load($ARGS{'Queue'}); unless ( $Queue->id ) { Abort('Queue not found'); } unless ( $Queue->CurrentUserHasRight('CreateTicket') ) { Abort('You have no permission to create tickets in that queue.'); } ($Ticket, @Actions) = CreateTicket( Attachments => delete $session{'Attachments'}, %ARGS, ); unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) { Abort("No permission to view newly created ticket #".$Ticket->id."."); } } else { $Ticket ||= LoadTicket($ARGS{'id'}); $m->callback( CallbackName => 'BeforeProcessArguments', TicketObj => $Ticket, ActionsRef => \@Actions, ARGSRef => \%ARGS ); if ( defined $ARGS{'Action'} ) { if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) { my $action = $1; my ($res, $msg) = $Ticket->$action(); push(@Actions, $msg); } } $m->callback(CallbackName => 'ProcessArguments', Ticket => $Ticket, ARGSRef => \%ARGS, Actions => \@Actions); $ARGS{UpdateAttachments} = $session{'Attachments'}; push @Actions, ProcessUpdateMessage( ARGSRef => \%ARGS, Actions => \@Actions, TicketObj => $Ticket, ); delete $session{'Attachments'}; #Process status updates push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket ); push @Actions, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $Ticket ); push @Actions, ProcessTicketLinks( ARGSRef => \%ARGS, TicketObj => $Ticket ); push @Actions, ProcessTicketDates( ARGSRef => \%ARGS, TicketObj => $Ticket ); push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket ); push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket ); unless ($Ticket->CurrentUserHasRight('ShowTicket')) { if (@Actions) { Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions); } else { Abort("No permission to view ticket"); } } if ( $ARGS{'MarkAsSeen'} ) { $Ticket->SetAttribute( Name => 'User-'. $Ticket->CurrentUser->id .'-SeenUpTo', Content => $Ticket->LastUpdated, ); push @Actions, loc('Marked all messages as seen'); } } $m->callback( CallbackName => 'BeforeDisplay', TicketObj => \$Ticket, Actions => \@Actions, ARGSRef => \%ARGS, ); # This code does automatic redirection if any updates happen. if (@Actions) { # We've done something, so we need to clear the decks to avoid # resubmission on refresh. # But we need to store Actions somewhere too, so we don't lose them. my $key = Digest::MD5::md5_hex( rand(1024) ); push @{ $session{"Actions"}->{$key} ||= [] }, @Actions; $session{'i'}++; my $url = RT->Config->Get('WebURL') . "m/ticket/show?id=" . $Ticket->id . "&results=" . $key; $url .= '#' . $ARGS{Anchor} if $ARGS{Anchor}; RT::Interface::Web::Redirect($url); } # If we haven't been passed in an Attachments object (through the precaching mechanism) # then we need to find one my $Attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket); my %documents; while ( my $attach = $Attachments->Next() ) { next unless ($attach->Filename()); unshift( @{ $documents{ $attach->Filename } }, $attach ); } my $CustomFields = $Ticket->CustomFields; $m->callback( CallbackName => 'MassageCustomFields', Object => $Ticket, CustomFields => $CustomFields, ); my $print_value = sub { my ($cf, $value) = @_; my $linked = $value->LinkValueTo; if ( defined $linked && length $linked ) { my $linked = $m->interp->apply_escapes( $linked, 'h' ); $m->out(''); } my $comp = "ShowCustomField". $cf->Type; $m->callback( CallbackName => 'ShowComponentName', Name => \$comp, CustomField => $cf, Object => $Ticket, ); if ( $m->comp_exists( $comp ) ) { $m->comp( $comp, Object => $value ); } else { $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) ); } $m->out('') if defined $linked && length $linked; # This section automatically populates a div with the "IncludeContentForValue" for this custom # field if it's been defined if ( $cf->IncludeContentForValue ) { my $vid = $value->id; $m->out( '
' ); $m->print( loc("See also:") ); $m->out( '' ); $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') ); $m->out( qq{
\n} ); $m->out( qq{\n} ); } }; <&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &>
<& /m/_elements/ticket_menu, ticket => $Ticket &> <&| /Widgets/TitleBox, title => loc('The Basics'), class => 'ticket-info-basics', &>
<&|/l&>Id:
<%$Ticket->Id %>
<&|/l&>Status:
<% loc($Ticket->Status) %>
% if ($Ticket->TimeEstimated) {
<&|/l&>Estimated:
<& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &>
% } % if ($Ticket->TimeWorked) {
<&|/l&>Worked:
<& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeWorked &>
% } % if ($Ticket->TimeLeft) {
<&|/l&>Left:
<& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeLeft &>
% }
<&|/l&>Priority:
<& /Ticket/Elements/ShowPriority, Ticket => $Ticket &>
<&|/l&>Queue:
<& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &>
<&|/l&>Bookmark:
<& /Ticket/Elements/Bookmark, id => $Ticket->id &>
% if ($Ticket->CustomFields->First) { <&| /Widgets/TitleBox, title => loc('Custom Fields'), class => 'ticket-info-cfs', &> % while ( my $CustomField = $CustomFields->Next ) { % my $Values = $Ticket->CustomFieldValues( $CustomField->Id ); % my $count = $Values->Count;
<% $CustomField->Name %>:
% unless ( $count ) { <&|/l&>(no value) % } elsif ( $count == 1 ) { % $print_value->( $CustomField, $Values->First ); % } else {
    % while ( my $Value = $Values->Next ) {
  • % $print_value->( $CustomField, $Value );
  • % }
% }
% } % } <&| /Widgets/TitleBox, title => loc('People'), class => 'ticket-info-people' &>
<&|/l&>Owner:
<& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket &>
<&|/l&>Requestors:
<& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket &>
<&|/l&>Cc:
<& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket &>
<&|/l&>AdminCc:
<& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket &>
% if (keys %documents) { <&| /Widgets/TitleBox, title => loc('Attachments'), title_class=> 'inverse', class => 'ticket-info-attachments', color => "#336699" &> % foreach my $key (keys %documents) { <%$key%>
% } % } % # too painful to deal with reminders % if ( 0 && RT->Config->Get('EnableReminders') ) { <&|/Widgets/TitleBox, title => loc("Reminders"), class => 'ticket-info-reminders', &>
<& /Ticket/Elements/Reminders, Ticket => $Ticket, ShowCompleted => 0 &>
% } <&| /Widgets/TitleBox, title => loc("Dates"), class => 'ticket-info-dates', &>
<&|/l&>Created:
<% $Ticket->CreatedObj->AsString %>
<&|/l&>Starts:
<% $Ticket->StartsObj->AsString %>
<&|/l&>Started:
<% $Ticket->StartedObj->AsString %>
<&|/l&>Last Contact:
<% $Ticket->ToldObj->AsString %>
<&|/l&>Due:
% my $due = $Ticket->DueObj; % if ( $due && $due->Unix > 0 && $due->Diff < 0 ) {
<% $due->AsString %>
% } else {
<% $due->AsString %>
% }
<&|/l&>Closed:
<% $Ticket->ResolvedObj->AsString %>
<&|/l&>Updated:
% my $UpdatedString = $Ticket->LastUpdated ? loc("[_1] by [_2]", $Ticket->LastUpdatedAsString, $Ticket->LastUpdatedByObj->Name) : loc("Never");
<% $UpdatedString | h %>
<&| /Widgets/TitleBox, title => loc('Links'), class => 'ticket-info-links' &>
<% loc('Depends on')%>:
<%PERL> my ( @active, @inactive, @not_tickets ); for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) { my $target = $link->TargetObj; if ( $target && $target->isa('RT::Ticket') ) { if ( $target->QueueObj->IsInactiveStatus( $target->Status ) ) { push( @inactive, $link->TargetURI ); } else { push( @active, $link->TargetURI ); } } else { push( @not_tickets, $link->TargetURI ); } }
    % for my $Link (@not_tickets, @active, @inactive) {
  • <& /Elements/ShowLink, URI => $Link &>
  • % }
<% loc('Depended on by')%>:
    % while (my $Link = $Ticket->DependedOnBy->Next) {
  • <& /Elements/ShowLink, URI => $Link->BaseURI &>
  • % }
<% loc('Parents') %>:
<& /Ticket/Elements/ShowParents, Ticket => $Ticket &>
<% loc('Children')%>:
<& /Ticket/Elements/ShowMembers, Ticket => $Ticket &>
<% loc('Refers to')%>:
    % while (my $Link = $Ticket->RefersTo->Next) {
  • <& /Elements/ShowLink, URI => $Link->TargetURI &>
  • % }
<% loc('Referred to by')%>:
    % while (my $Link = $Ticket->ReferredToBy->Next) { % next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket') && $Link->BaseObj->Type eq 'reminder');
  • <& /Elements/ShowLink, URI => $Link->BaseURI &>
  • % }