%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2016 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 }}} <& /RTIR/Elements/Header, Title => loc("Incident #[_1]: [_2]", $id, $TicketObj->Subject) &> <& /Elements/Tabs &> % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $TicketObj); <& /Elements/ListActions, actions => \@results &> <& /Ticket/Elements/ShowUpdateStatus, Ticket => $TicketObj, DisplayPath => 'RTIR' &>
<&| /Widgets/TitleBox, title => loc('Ticket metadata') &>
% $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'LeftColumnStart' ); <&| /Widgets/TitleBox, title => loc('Incident #[_1]', $id), title_href => RT::IR->HREFTo("Edit.html?id=".$id), class=> 'ticket-info-basics', &> % if (my $constituency = RT::IR->ConstituencyFor($TicketObj)) { % } <& /Elements/ShowCustomFields, Grouping => 'Basics', Object => $TicketObj, Table => 0 &>
<% loc("Constituency") %>: <% $constituency %>
<% loc("Queue") %>: <% $TicketObj->QueueObj->Name %>
<% loc("Status") %>: <% $TicketObj->Status %>
<&|/l&>Owner: <& /Elements/ShowUser, User => $TicketObj->OwnerObj &>
<&|/l&>Subject: <% $TicketObj->Subject %>
<&|/l&>Priority: <& /Ticket/Elements/ShowPriority, Ticket => $TicketObj &>
<&|/l&>Time Worked: <%loc('[_1] min', $TimeWorked)%>
<& /Elements/ShowCustomFieldCustomGroupings, Object => $TicketObj, title_href => RT::IR->HREFTo("Edit.html"), &> <&| /Widgets/TitleBox, title => loc("Dates"), title_href =>RT::IR->HREFTo("Edit.html?id=".$id), class => 'ticket-info-dates', &> <& /RTIR/Elements/ShowDates, Ticket => $TicketObj &> <& /Ticket/Elements/ShowAttachments, Ticket => $TicketObj, Attachments => $attachments &> <& /Ticket/Elements/ShowRequestor, Ticket => $TicketObj, DisplayPath => RT::IR->HREFTo("Display.html") &>
% $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'RightColumnStart' ); % foreach my $lifecycle ( RT::IR->lifecycle_report, RT::IR->lifecycle_investigation, RT::IR->lifecycle_countermeasure ) { <& /RTIR/Incident/Elements/ShowChildren, IncidentObj => $TicketObj, Lifecycle => $lifecycle &> % } <& /RTIR/Elements/ShowArticles, Ticket => $TicketObj &>
% my $ShowHistory = RT->Config->Get("ShowHistory", $session{'CurrentUser'}); % if ($ShowHistory eq "scroll") { <& /Ticket/Elements/ScrollShowHistory, Ticket => $TicketObj &> % } elsif ($ShowHistory eq "delay") { <& /Ticket/Elements/DelayShowHistory, Ticket => $TicketObj, ShowHeaders => $ARGS{'ShowHeaders'}, &> % } elsif (not $ForceShowHistory and $ShowHistory eq "click") { <& /Ticket/Elements/ClickToShowHistory, Ticket => $TicketObj, ShowHeaders => $ARGS{'ShowHeaders'}, &> % } else { <& /Elements/ShowHistory, Object => $TicketObj, ShowHeaders => $ARGS{'ShowHeaders'}, DisplayPath => RT::IR->HREFTo("Display.html?id=$id"), UpdatePath => RT::IR->HREFTo("Update.html"), ForwardPath => RT::IR->HREFTo("Forward.html"), EncryptionPath => RT::IR->HREFTo("Crypt.html"), PathPrefix => RT::IR->HREFTo("Ticket/") &> % } <%INIT> if ($SelectedTicket) { $id = $SelectedTicket; $ARGS{'Status'} = "open"; } Abort('No incident specified') unless $id; if( $Child ) { my $ChildObj = RT::Ticket->new( $session{'CurrentUser'} ); $ChildObj->Load($Child); $m->callback(CallbackName => 'ThisLinkedToIR', ARGSRef => \%ARGS, Child => $ChildObj); } my $take_or_steal = sub { my $owner = $_[0]->Owner; return () if $owner == $session{'CurrentUser'}->id; my $action = 'Steal'; $action = 'Take' if $owner == $RT::Nobody->id; my ($res, $msg) = $_[0]->$action(); return $msg || (); }; my $deleted_links = 0; my $DoLinks = sub { my ($child, $parent) = @_; my %args = (); if (RT::IR->StrictConstituencyLinking) { if ((RT::IR->ConstituencyFor($child) ||'') ne (RT::IR->ConstituencyFor($parent) ||'')) { return loc("Link failed: Ticket #[_1] is associated with a different constituency", $child->id ); } } # Countermeasure or Incident Reports can have multiple incidents my $Type = RT::IR::TicketType( Ticket => $child ); my $config = RT->Config->Get('RTIR_IncidentChildren')->{$Type}; unless( $config->{'Multiple'} ) { my $incidents = RT::IR->Incidents( $child, Exclude => $parent ); while ( my $incident = $incidents->Next ) { $deleted_links = 1; $args{'DeleteLink--MemberOf-'. $incident->id } = ''; } } my @results; # if we don't own any of ends, take or steal parent unless ( $parent->Owner == $session{'CurrentUser'}->id || $child->Owner == $session{'CurrentUser'}->id ) { push @results, $take_or_steal->( $parent ); } # turn off strict check locally my $strict_acl = RT->Config->Set( StrictLinkACL => 0 ); $args{ $child->Id .'-MemberOf' } = $parent->Id; push @results, ProcessTicketLinks( TicketObj => $child, ARGSRef => \%args ); RT->Config->Set( StrictLinkACL => $strict_acl ); return map { loc("Ticket [_1]: [_2]", $child->Id, $_) } @results; }; my @results; my $TicketObj; my $new_ticket = 0; if ( $id eq 'new' ) { my $QueueObj = RT::Queue->new( $session{'CurrentUser'} ); $QueueObj->Load( $Queue ) || Abort(loc("Couldn't load queue.")); unless( RT::IR->IsIncidentQueue($QueueObj) ) { return $m->comp('/RTIR/Display.html', %ARGS ); } ($TicketObj, @results) = CreateTicket( %ARGS ); $new_ticket = 1; } else { $TicketObj = LoadTicket( $id ); } $m->callback(CallbackName => 'ProcessArguments', Ticket => $TicketObj, ARGSRef => \%ARGS, Actions => \@results); unless( RT::IR->IsIncidentQueue($TicketObj->QueueObj) ) { return $m->comp('/RTIR/Display.html', %ARGS ); } $ARGS{'id'} = $id = $TicketObj->Id; if ( $ARGS{'Action'} && $ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/ ) { my $action = $1; my ($res, $msg) = $TicketObj->$action(); push @results, $msg; # If they succeeded in taking the ticket, they should also get a lock if ($res && $action =~ /^(?:Take|Steal)$/) { $ARGS{'Lock'} = 'add'; } } unless( $new_ticket ) { push @results, ProcessTicketBasics( ARGSRef => \%ARGS, TicketObj => $TicketObj ); } if ( $ARGS{'BulkLink'} || $Child ) { my @link; push @link, @SelectedTickets if $ARGS{'BulkLink'}; push @link, $Child if $Child; foreach my $id ( grep $_, @link ) { my $child = RT::Ticket->new( $session{'CurrentUser'} ); $child->Load( $id ); unless( $child->id ) { push @results, loc("Couldn't load ticket #[_1] for linking.", $id); next; } push @results, $DoLinks->( $child, $TicketObj ); } } # If we deleted any links, check if what we deleted from still has children if ( $deleted_links && !RT::IR->IncidentChildren( $TicketObj )->Count ) { push @results, loc("WARNING: Incident [_1] has no children.", $id); } if ( $ARGS{'BulkArticles'} && @SelectedTickets ) { my $ref = join " ", map "a:$_", @SelectedTickets; push @results, ProcessTicketLinks( TicketObj => $TicketObj, ARGSRef => {$TicketObj->Id."-RefersTo" => $ref} ); } unless( $new_ticket ) { push @results, ProcessUpdateMessage( ARGSRef => \%ARGS, TicketObj => $TicketObj, Actions => \@results ); } if ( $ARGS{'MarkAsSeen'} ) { $TicketObj->SetAttribute( Name => 'User-'. $TicketObj->CurrentUser->id .'-SeenUpTo', Content => $TicketObj->LastUpdated, ); push @results, loc('Marked all messages as seen'); } MaybeRedirectForResults( Actions => \@results, Path => RT::IR->HREFTo("Display.html", IncludeWebPath => 0), Arguments => { id => $TicketObj->id }, Anchor => $ARGS{'Anchor'}, ); # XXX: need the way to show @results when aborting unless ( $TicketObj->CurrentUserHasRight('ShowTicket') ) { Abort("No permission to view ticket #$id."); } my $TimeWorked = $TicketObj->TimeWorked; if ( defined $TicketObj->TimeLeft && $TicketObj->TimeLeft > 0 ) { $TimeWorked .= '/'. $TicketObj->TimeLeft; } my $attachments = $TicketObj->Attachments; <%ARGS> $id => undef $Queue => RT::IR->lifecycle_incident $Child => undef $SelectedTicket => undef @SelectedTickets => () $ForceShowHistory => 0