Commit 3db519e8 authored by Ruslan Zakirov's avatar Ruslan Zakirov
Browse files

RT::IR->MapStatus( $status, $from => $to ) method

parent e0702e3b
......@@ -144,18 +144,9 @@ if ( $SubmitTicket && !$checks_failure ) {
push @results, map { loc("Ticket [_1]: [_2]", $id, $_) }
ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
my %additional;
if ( $Status ) {
$additional{'Status'} = $incident_cycle->MoveMap(
$Ticket->QueueObj->Lifecycle
)->{ $Status };
unless ( $additional{'Status'} ) {
RT->Logger->error(
"No mapping for $Status in Incidents queue"
.' to status in '. $Ticket->QueueObj->Name .' queue'
);
}
}
my %additional = (
Status => RT::IR->MapStatus( $Status, $incident_cycle => $Ticket ),
);
unless ( RT::IR->IsLinkedToActiveIncidents( $Ticket, $IncidentObj ) ) {
push @results, ProcessTicketBasics(
......
......@@ -418,6 +418,40 @@ sub IsLinkedToActiveIncidents {
return $tickets->Count;
}
sub MapStatus {
my $self = shift;
my ($status, $from, $to) = @_;
return unless $status;
foreach my $e ($from, $to) {
if ( blessed $e ) {
if ( $e->isa('RT::Queue') ) {
$e = $e->Lifecycle;
}
elsif ( $e->isa('RT::Ticket') ) {
$e = $e->QueueObj->Lifecycle;
}
elsif ( !$e->isa('RT::Lifecycle') ) {
$e = undef;
}
}
else {
my $queue = RT::Queue->new( RT->SystemUser );
$queue->Load( $e );
$e = $queue->Lifecycle;
}
return unless $e;
}
my $res = $from->MoveMap( $to )->{ $status };
unless ( $res ) {
RT->Logger->warning(
"No mapping for $status in ". $from->Name .' lifecycle'
.' to status in '. $to->Name .' lifecycle'
);
}
return $res;
}
sub GetCustomField {
my $field = shift or return;
return (__PACKAGE__->CustomFields( $field ))[0];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment