Created
March 6, 2014 08:50
-
-
Save reneeb/9385477 to your computer and use it in GitHub Desktop.
Sample event module
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
<?xml version="1.0" encoding="iso-8859-1"?> | |
<otrs_config version="1.0" init="Application"> | |
<CVS>$Id: EventModule.xml,v 1.12 2008/03/10 12:57:42 mh Exp $</CVS> | |
<ConfigItem Name="Ticket::EventModulePost###100-AutoPriority" Required="0" Valid="1"> | |
<Description Translatable="1">Set Priority automatically.</Description> | |
<Group>OTRS-Workshop</Group> | |
<SubGroup>EventModule</SubGroup> | |
<Setting> | |
<Hash> | |
<Item Key="Module">Kernel::System::Ticket::Event::Priority</Item> | |
<Item Key="Event">(TicketCreate)</Item> | |
</Hash> | |
</Setting> | |
</ConfigItem> | |
<ConfigItem Name="Workshop::Priority" Required="1" Valid="1"> | |
<Description Translatable="1">Set priority of new tickets to this priority.</Description> | |
<Group>OTRS-Workshop</Group> | |
<SubGroup>EventModule</SubGroup> | |
<Setting> | |
<String Regex="">5 very high</String> | |
</Setting> | |
</ConfigItem> | |
</otrs_config> |
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/Ticket/Event/Priority.pm - set priority automagically | |
# Copyright (C) 2012 Perl-Services.de, http://perl-services.de | |
# -- | |
# $Id: Priority.pm,v 1.2 2010/05/14 12:44:56 martin Exp $ | |
# -- | |
# 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::Ticket::Event::Priority; | |
use strict; | |
use warnings; | |
use vars qw($VERSION); | |
$VERSION = qw($Revision: 1.2 $) [1]; | |
sub new { | |
my ( $Type, %Param ) = @_; | |
# allocate new hash for object | |
my $Self = {}; | |
bless( $Self, $Type ); | |
# get needed objects | |
for ( | |
qw(ConfigObject TicketObject LogObject UserObject CustomerUserObject SendmailObject TimeObject EncodeObject) | |
) | |
{ | |
$Self->{$_} = $Param{$_} || die "Got no $_!"; | |
} | |
return $Self; | |
} | |
sub Run { | |
my ( $Self, %Param ) = @_; | |
# check needed stuff | |
for (qw(Data Event Config)) { | |
if ( !$Param{$_} ) { | |
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" ); | |
return; | |
} | |
} | |
for (qw(TicketID)) { | |
if ( !$Param{Data}->{$_} ) { | |
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $_ in Data!" ); | |
return; | |
} | |
} | |
if ( $Param{Event} eq 'TicketCreate' ) { | |
my $Priority = $Self->{ConfigObject}->Get( 'Workshop::Priority' ); | |
my %Ticket = $Self->{TicketObject}->TicketGet( TicketID => $Param{Data}->{TicketID} ); | |
if ( $Ticket{State} eq 'Test' ) { | |
# do some stuff | |
$Self->{TicketObject}->TicketPrioritySet( | |
TicketID => $Param{Data}->{TicketID}, | |
UserID => $Param{UserID}, | |
Priority => $Priority, | |
); | |
} | |
} | |
return 1; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment