%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2003 Jesse Vincent %# %# (Except where explictly superceded by other copyright notices) %# %# 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. %# %# %# Unless otherwise specified, all modifications, corrections or %# extensions to this work which alter its source code become the %# property of Best Practical Solutions, LLC when submitted for %# inclusion in the work. %# %# %# END LICENSE BLOCK <& /RTIR/Elements/Header, Title => $Title &> % my $EscapedQueue = $m->comp('/Elements/QueryString', Queue => $Queue ); % if ( $Split ) { <& '/RTIR/'.$Type.'/Elements/Tabs', Title => $Title, Ticket => $TicketObj, current_tab => "RTIR/Split.html?Ticket=".$TicketObj->Id, current_subtab => "RTIR/Split.html?Ticket=".$TicketObj->Id, &> % } elsif ( $Incident ) { <& "/RTIR/Search/Elements/RefineTabs", Title => $Title, Ticket => $IncidentObj, Queue => $Queue, current_tab => "RTIR/Create.html?Incident=$Incident&$EscapedQueue", &> % } else { <& "/RTIR/".$Type."/Elements/Tabs", Title => $Title, Ticket => $TicketObj, current_tab => "RTIR/Create.html?$EscapedQueue", current_subtab => "RTIR/Create.html?$EscapedQueue", &> % } % $m->callback(CallbackName => 'BeforeActionList', %ARGS, Actions => \@results, ARGSRef => \%ARGS, Ticket => $TicketObj); <& /Elements/ListActions, actions => \@results &> % if ( $Split && !$TicketObj->CurrentUserHasRight('ModifyTicket') ) { <% loc("You are not allowed to split this [_1].", $name) %> % $m->abort(); % } % unless ( $Split ) {
% } else { % } % if ( $Split ) { % } <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &> <&| /Widgets/TitleBox, title => $Title &> % if ( $Incident ) { % } elsif ( $TicketObj ) { % if ( $parentvalue ) { % } % } else { % } % $m->callback( CallbackName => 'AfterRequestors', ARGSRef => \%ARGS ); % if ( $constituency_cf ) { % } % if ( $Type eq "Investigation" && $IncidentObj ) { % } % if ( $gnupg_widget ) { % }
<&|/l&>Incident: <% $Incident %>
<&|/l&>Split from: <% $TicketObj->id %>
<&|/l&>Will be linked to Incident(s): <% $parentvalue %>
<&|/l&>Incident: (<&|/l&>Id of an Incident to link a new ticket to. <% $Type eq 'Block'? ''.loc('Required').'': loc('Optional') |n %>.)
<&|/l&>Owner: <& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj, Default => $ARGS{Owner}||$session{'CurrentUser'}->Id||undef &>
<&|/l&>Subject:
<&|/l&>Time Worked:
<&|/l&>Time Left:
<&|/l&>Correspondents: /> <&|/l&>Don't send any emails to correspondents.
<&|/l&>Cc: <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of email addresses. These people will receive future updates.)
<&|/l&>Admin Cc: <&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of administrative email addresses. These people will receive future updates.)
<&|/l&>Constituency: % if ( !$Incident || RT->Config->Get('_RTIR_Constituency_Propagation') eq 'no' ) { % my $default; % $default = $IncidentObj->FirstCustomFieldValue('Constituency') if $Incident; % $default ||= RT::IR::DefaultConstituency( $QueueObj ); % $default ||= scalar RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'}; <& /RTIR/Elements/EditRTIRField, QueueObj => $QueueObj, Name => 'Constituency', Default => $default &> % } else { % #TODO: hacks, we need way to define CF value on Create, but don't allow user to change it <& /RTIR/Elements/ShowRTIRField, Ticket => $IncidentObj, Name => 'Constituency' &> % }
<& /RTIR/Elements/EditCustomFields, TicketObj => $TicketObj, QueueObj => $QueueObj, $Split ? ( OnCreate => 1 ) : (), $IncidentObj ? ( IncidentObj => $IncidentObj ) : (), &>
<& SELF:AttachmentsForm &>
<& /RTIR/Elements/AttachReports, Ticket => $IncidentObj &>
  <& /Elements/GnuPG/SignEncryptWidget, self => $gnupg_widget, QueueObj => $QueueObj &>
<&|/l&>Message: % my $include_signature = 1; % unless (exists $ARGS{Content}) { % my $Transactions; % if ($TicketObj) { % $Transactions = $TicketObj->Transactions; % } elsif ($IncidentObj) { % $Transactions = $IncidentObj->Transactions; % } % % if ($Transactions) { % # Investigations should quote their included text % my $quote = 0; % if ($Type eq 'Investigation') { % $quote = 1; % } % $ARGS{Content} = $m->scomp("/RTIR/Elements/TransactionData", % Transactions => $Transactions, % Type => 'messages', % Include => {'Create', 'Correspond'}, % QuoteText => $quote); % $ARGS{Content} =~ s/\>/>/g; % } % } else { % $include_signature = 0; % } % $m->callback( %ARGS, CallbackPage => '/Ticket/Create.html', CallbackName => 'BeforeMessageBox' ); % if ( $ARGS{Content} ) { <& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => $include_signature &> % } else { <& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &> % }
<&| /Widgets/TitleBox, title => loc("Dates"), class => 'ticket-info-dates' &>
<&|/l&>Starts:
<&|/l&>Due:
<& /Elements/Submit, Name => "Create", Label => $SubmitCaption &>
<%INIT> $m->callback( CallbackName => 'Init', CallbackPage => '/Ticket/Create.html', ARGSRef => \%ARGS, ); my $QueueObj = new RT::Queue( $session{'CurrentUser'} ); $QueueObj->Load( $Queue ) || Abort( loc("Queue could not be loaded.") ); my $Type = RT::IR::TicketType( Queue => $Queue ); if ($Type eq 'Block' && RT->Config->Get('RTIR_DisableBlocksQueue') ) { Abort(loc("Blocks queue is disabled via config file")); } if ( $m->comp_exists("/RTIR/$Type/Create.html") ) { return $m->comp( "/RTIR/$Type/Create.html", %ARGS ); } my ($Status, $name); if ( $Type eq 'Report' ) { $name = 'Incident Report'; $Status = 'new'; } elsif ( $Type eq 'Investigation' ) { $Status = 'open'; } elsif ( $Type eq 'Block' ) { $Status = 'new'; } $name ||= $Type; my (@results, $checks_failure, $skip_create); $skip_create = !$ARGS{'Create'}; my $constituency_cf = RT::IR->CustomFields( 'Constituency', Queue => $Queue ); my $constituency_field; $constituency_field = 'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values' if $constituency_cf; my $IncidentObj; if ( $Incident ) { $IncidentObj = RT::Ticket->new( $session{'CurrentUser'} ); $IncidentObj->Load( $Incident ); unless ( $IncidentObj->id ) { push @results, loc("Couldn't load incident #[_1]", $Incident ); ($checks_failure, $IncidentObj, $Incident) = (1, undef, undef); } elsif ( $IncidentObj->QueueObj->Name ne 'Incidents' ) { push @results, loc('Ticket #[_1] is not an Incident', $Incident ); ($checks_failure, $IncidentObj, $Incident) = (1, undef, undef); } elsif ( !$skip_create && $constituency_field && RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject' && lc $ARGS{$constituency_field} ne lc $IncidentObj->FirstCustomFieldValue('Constituency') ) { push @results, loc('Incident #[_1] has constituency [_2], choose the same value for a new ticket or use another Incident', $Incident, $IncidentObj->FirstCustomFieldValue('Constituency') ); ($checks_failure, $IncidentObj, $Incident) = (1, undef, undef); } else { $Subject ||= $IncidentObj->Subject; } } $Incident = $ARGS{'Incident'} = $IncidentObj->id if $IncidentObj; my $parentvalue = ''; if ( $IncidentObj ) { $parentvalue = $IncidentObj->Id; } elsif ( $TicketObj ) { my $incidents = RT::Tickets->new( $session{'CurrentUser'} ); $incidents->FromSQL( "Queue = 'Incidents' AND HasMember = " . $TicketObj->Id ); while ( my $incident = $incidents->Next ) { $parentvalue .= ' ' if $parentvalue; $parentvalue .= $incident->Id; } } push @results, $m->comp( 'SELF:ProcessAttachments', %ARGS ); my $gnupg_widget = $m->comp('/Elements/GnuPG/SignEncryptWidget:new', Arguments => \%ARGS ); $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process', self => $gnupg_widget, QueueObj => $QueueObj, ); if ( !$skip_create && $gnupg_widget ) { my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check', self => $gnupg_widget, Operation => 'Create', QueueObj => $QueueObj, ); $checks_failure = 1 unless $status; } unless ( $skip_create ) { if ( $Type eq 'Investigation' && !$ARGS{'Requestors'} ) { push @results, loc( "You must enter a correspondent" ); $checks_failure = 1; } elsif ( $Type eq 'Block' and not $IncidentObj ) { push @results, loc( "You must enter an Incident ID" ); $checks_failure = 1; } my $TicketCFs = $QueueObj->TicketCustomFields; my ($status, @msg) = $m->comp('/Elements/ValidateCustomFields', CustomFields => $TicketCFs, ARGSRef => \%ARGS, ); unless ( $status ) { push @results, loc( "Invalid value(s) of the custom fields:" ); while (my $CF = $TicketCFs->Next) { my $msg = $m->notes('InvalidField-' . $CF->Id) or next; push @results, $CF->Name . ': ' . $msg; } $checks_failure = 1; } } # for RTFM and other things $m->callback( CallbackName => 'BeforeCreate', CallbackPage => '/Ticket/Create.html', ARGSRef => \%ARGS, results => \@results, skip_create => \$skip_create, checks_failure => $checks_failure ); unless ( $skip_create || $checks_failure ) { $ARGS{'new-MemberOf'} = $parentvalue if $parentvalue; $m->callback(CallbackName => 'BeforeDisplay', Ticket => $TicketObj, ARGSRef => \%ARGS); push @{ $session{'Actions'}{''} ||= [] }, @results; return $m->comp( 'Display.html', %ARGS, SkipNotification => \@SkipNotification ); } unshift @results, loc("Creation failed:") if $checks_failure && @results; my ($Title, $SubmitCaption); if ( $Split ) { $Title = loc("Split [_1] #[_2]: [_3]", $name, $TicketObj->id, $TicketObj->Subject); $SubmitCaption = loc("Split"); } else { if ( $Type eq 'Investigation' ) { $Title = loc("Launch a new [_1]", $name); $SubmitCaption = loc("Launch"); } else { $Title = loc("Create a new [_1]", $name); $SubmitCaption = loc("Create"); } } <%ARGS> $Queue => undef @SkipNotification => () $Subject => undef $QuoteTransaction => undef # Parent Incident $Incident => undef $Split => 0 # Split source $TicketObj => undef <%METHOD ProcessAttachments> <%ARGS> @DeleteAttachments => () $Attachment => ''; <%INIT> my @results; $session{'Attachments'} ||= {}; # deal with deleting uploaded attachments foreach ( grep $_ && exists $session{'Attachments'}{ $_ }, @DeleteAttachments ) { delete $session{'Attachments'}{ $_ }; push @results, loc("Deleted attachment '[_1]'", $_ ); $session{'i'}++; } # store the uploaded attachment in session if ( $Attachment ) { my $filename = "$Attachment"; $filename =~ s{^.*[\\/]}{}; my $entity = MakeMIMEEntity( Subject => $filename, Body => '', AttachmentFieldName => 'Attachment' ); $session{'Attachments'}{ $filename } = $entity; push @results, loc("Added attachment '[_1]'", $filename ); $session{'i'}++; } return @results; <%METHOD AttachmentsForm> % my $has_files = exists $session{'Attachments'} && keys %{ $session{'Attachments'} }; % if ( $has_files ) { % }
<&|/l&>Attached file: <&|/l&>Check box to delete
    % foreach my $name ( keys %{$session{'Attachments'}} ) {
  • <% $name %>
  • % }
<&|/l&>Attach file: