Created
March 9, 2016 17:13
-
-
Save reneeb/7308b1cb390a26c1bfe5 to your computer and use it in GitHub Desktop.
Sample Postmaster filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Self->{'PostMaster::PostFilterModule'}->{'9931313-SetQueue'} = { | |
Module => 'Kernel::System::PostMaster::Filter::SetQueue', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- | |
# Kernel/System/PostMaster/Filter/SetQueue.pm - the global PostMaster module for OTRS | |
# Copyright (C) 2016 Perl-Services.de, http://perl-services.de | |
# -- | |
# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
# the enclosed file COPYING for license information (AGPL). If you | |
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
# -- | |
package Kernel::System::PostMaster::Filter::SetQueue; | |
use strict; | |
our @ObjectDependencies = qw( | |
Kernel::System::Ticket | |
Kernel::System::Log | |
); | |
sub new { | |
my $Type = shift; | |
my %Param = @_; | |
# allocate new hash for object | |
my $Self = {}; | |
bless( $Self, $Type ); | |
return $Self; | |
} | |
sub Run { | |
my ( $Self, %Param ) = @_; | |
my $LogObject = $Kernel::OM->Get('Kernel::System::Log'); | |
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket'); | |
for my $Needed (qw(TicketID JobConfig GetParam)) { | |
if ( !$Param{$Needed} ) { | |
$LogObject->Log( | |
Priority => 'error', | |
Message => "Need $Needed!", | |
); | |
return; | |
} | |
} | |
my %Ticket = $TicketObject->TicketGet( | |
TicketID => $Param{TicketID}, | |
UserID => 1, | |
); | |
return 1 if $Ticket{Queue} ne 'Queue1'; | |
return 1 if $Ticket{StateType} ne 'closed'; | |
$TicketObject->TicketQueueSet( | |
TicketID => $Param{TicketID}, | |
Queue => 'NewQueue', | |
UserID => 1, | |
); | |
$TicketObject->TicketStateSet( | |
TicketID => $Param{TicketID}, | |
State => 'open', | |
UserID => 1, | |
); | |
return 1; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment