%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2013 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 &>
<&| /Widgets/TitleBox, title => loc('Ticket metadata') &>
% $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'LeftColumnStart' ); <&| /Widgets/TitleBox, title => loc('Incident #[_1]', $id), title_href => RT->Config->Get('WebPath') ."/RTIR/Edit.html?id=".$id, class=> 'ticket-info-basics', &> <& /Elements/ShowCustomFields, Object => $TicketObj, Table => 0 &>
<% 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)%>
<&| /Widgets/TitleBox, title => loc("Dates"), title_href => RT->Config->Get('WebPath') ."/RTIR/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 => "/RTIR/Display.html" &>
% $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'RightColumnStart' ); % foreach my $queue ( 'Incident Reports', 'Investigations', 'Blocks' ) { <& /RTIR/Incident/Elements/ShowChildren, IncidentObj => $TicketObj, Queue => $queue, &> % } <& /RTIR/Elements/ShowArticles, Ticket => $TicketObj &>
<& /Ticket/Elements/ShowHistory, Ticket => $TicketObj, Collapsed => $ARGS{'Collapsed'}, ShowHeaders => $ARGS{'ShowHeaders'}, DisplayPath => RT->Config->Get('WebPath') ."/RTIR/Display.html?id=$id", UpdatePath => RT->Config->Get('WebPath') ."/RTIR/Update.html", ForwardPath => RT->Config->Get('WebPath') ."/RTIR/Forward.html", EncryptionPath => RT->Config->Get('WebPath') ."/RTIR/GnuPG.html", &> <%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) = @_; if ( RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject' ) { return loc("Couldn't link tickets with different constituencies") if lc $child->FirstCustomFieldValue('Constituency') ne lc $parent->FirstCustomFieldValue('Constituency') && RT::IR->CustomFields('Constituency'); } my %args = (); # Blocks or Incedent 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 localy 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( $QueueObj->Name eq 'Incidents' ) { return $m->comp('/RTIR/Display.html', %ARGS ); } ($TicketObj, @results) = CreateTicket( %ARGS, Attachments => delete $session{'Attachments'} ); $new_ticket = 1; } else { $TicketObj = LoadTicket( $id ); } $m->callback(CallbackName => 'ProcessArguments', Ticket => $TicketObj, ARGSRef => \%ARGS, Actions => \@results); unless( $TicketObj->QueueObj->Name eq 'Incidents' ) { 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 ) { $ARGS{UpdateAttachments} = delete $session{'Attachments'}; push @results, ProcessUpdateMessage( ARGSRef => \%ARGS, TicketObj => $TicketObj ); } MaybeRedirectForResults( Actions => \@results, Path => "/RTIR/Display.html", Arguments => { id => $TicketObj->id }, ); # 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 = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $TicketObj); <%ARGS> $id => undef $Queue => 'Incidents' $Child => undef $SelectedTicket => undef @SelectedTickets => ()