%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2026 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 }}} <%INIT> my $constituency = $m->{'RTIR_ConstituencyFilter'}; my $ChildObj; if ( $Child ) { $ChildObj = LoadTicket( $Child ); $ARGS{'Subject'} ||= $ChildObj->Subject; } my $SplitObj; if ( $Split ) { $SplitObj = LoadTicket( $Split ); unless (@Incident) { @Incident = map $_->id, @{ RT::IR->Incidents( $SplitObj )->ItemsArrayRef || [] }; $ARGS{Incident} = \@Incident; } } @Incident = grep { /\d+/ } @Incident; my $IncidentObj; if ( @Incident ) { $IncidentObj = LoadTicket( $Incident[0] ); } for my $related_ticket ( $SplitObj, $ChildObj, $IncidentObj ) { next unless $related_ticket; my $related_constituency = RT::IR->ConstituencyFor($related_ticket); $constituency ||= $related_constituency; last; } # If the Queue is not passed in as an ARG, go get and set queue from the queues the user can CreateTicket. # For constituency users without access to the default RTIR queues we need to specifically check and limit # else we Abort below when we attempt to load the default queue as the user. unless ($Queue) { my $collection = RT::Queues->new($session{'CurrentUser'}); # RT::Queues::AddRecord verifies the user has 'SeeQueue', so we don't # need to specifically test for that in the while loop below. if ($Lifecycle) { $collection->Limit(FIELD => 'Lifecycle', OPERATOR => '=', VALUE => $Lifecycle); } else { $collection->Limit( FIELD => 'Lifecycle', OPERATOR => 'IN', VALUE => [RT::IR->Lifecycles], ); } if ($constituency) { $collection->Limit( FIELD => 'Name', OPERATOR => 'ENDSWITH', VALUE => "- $constituency", CASESENSITIVE => 0, ); } while (my $object = $collection->Next) { # Ensure the user can CreateTicket in the queue. next unless $session{CurrentUser}->HasRight( Object => $object, Right => 'CreateTicket' ); $Queue = $object->Id; last; } } Abort( loc( "Permission Denied" ) ) unless $Queue; my $QueueObj = RT::Queue->new( $session{'CurrentUser'} ); $QueueObj->Load( $Queue ); if (!$QueueObj->Name) { Abort( loc("Queue '[_1]' could not be loaded.",$Queue) ); } if ( !RT::IR->OurQueue($QueueObj) ) { RT::Interface::Web::Redirect( '/Ticket/Create.html?' . $m->comp( '/Elements/QueryString', %ARGS ) ); } $Lifecycle ||= $QueueObj->Lifecycle; if (RT::IR->IsCountermeasureQueue($QueueObj) && RT->Config->Get('RTIR_DisableCountermeasures') ) { Abort(loc("Countermeasure queues are disabled via config file")); } my $Type = RT::IR::TicketType( Lifecycle => $Lifecycle); my $children_config = RT->Config->Get('RTIR_IncidentChildren')->{ $Type }; if ( @Incident > 1 && !$children_config->{'Multiple'} ) { push @{ $m->{'request_args'} }, Incident => $Incident[-1]; @Incident = ($Incident[-1]); } $IncidentObj = LoadTicket( $Incident[0] ) if @Incident; $ARGS{Subject} ||= $IncidentObj->Subject if $IncidentObj; # As of RTIR 4.0, that's only true for Incidents # If there's an RTIR specific create page for this kind of ticket, show that if ( $Type && $m->comp_exists("/RTIR/$Type/Create.html") && $m->request_path !~ m{^/RTIR/(?:c/[^/]+/)?$Type/Create\.html} ) { RT::Interface::Web::Redirect( RT::IR->HREFTo( "$Type/Create.html?" . $m->comp( '/Elements/QueryString', %ARGS ) ) ); } my (@results, $checks_failure, $skip_create); $skip_create = !$ARGS{'Create'}; unless ( exists $ARGS{Content} ) { my $Transactions; if ($SplitObj) { $Transactions = $SplitObj->Transactions; } elsif ($IncidentObj) { $Transactions = $IncidentObj->Transactions; } if ($Transactions) { # Investigations should quote their included text my $quote = 0; if ( RT::IR->IsInvestigationQueue($QueueObj) ) { $quote = 1; } my $starting_content = $m->scomp( "/RTIR/Elements/TransactionData", Transactions => $Transactions, Type => 'messages', Include => { 'Create', 'Correspond' }, QuoteText => $quote, ); if ( defined $starting_content && length $starting_content ) { $starting_content =~ s/\>/>/g; $ARGS{Content} = $starting_content; } } } $m->comp( '/Ticket/Create.html', Requestors => '', Owner => $session{CurrentUser}->Id, %ARGS, $Split || $Child || $Incident[0] ? ( CloneTicket => $Split || $Child || $Incident[0] ) : (), Queue => $Queue ); <%ARGS> $Queue => undef $Lifecycle => undef # Parent Incident(s) @Incident => () $Split => undef $Child => undef