- HTML Admin-Manual
- PDF Admin-Manual
- HTML ITSM-Manual
- PDF ITSM-Manual
- HTML Developer-Manual
- PDF Developer-Manual
- HTML Developer-API
7.10. Ticket Modules
7.10.1. Ticket Number Module
If you want to create your own ticket number format, just create your own ticket number module. These modules are located under "Kernel/System/Ticket/Number/*.pm". For default modules see the admin manual. You just need 2 functions: CreateTicketNr() and GetTNByString():
Format:
# --
# Ticket/Number/Simple.pm - a ticket number auto increment generator
# Copyright (C) 2005 Hans Mueller mail@example.com
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
# Generates auto increment ticket numbers like ss.... (e. g. 1010138, 1010139, ...)
# --
package Kernel::System::Ticket::Number::Simple;
use strict; use vars qw($VERSION);
$VERSION = '$Revision: 1.21.2.1 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
sub CreateTicketNr {
my $Self = shift;
my $JumpCounter = shift || 0;
# get needed config options
[...]
return $Tn;
}
# --
sub GetTNByString {
my $Self = shift;
my $String = shift || return;
[...]
return $Tn;
}
1;
7.10.2. Ticket PostMaster Module
PostMaster modules are used during the PostMaster process. There are two kinds of PostMaster modules. PostMasterPre (used after parsing an email) and PostMasterPost (used after an email is processed and in the database) modules.
If you want to create your own postmaster filter, just create your own module. These modules are located under "Kernel/System/PostMaster/Filter/*.pm". For default modules see the admin manual. You just need two functions: new() and Run():
The following is an examplary module to match emails and set X-OTRS-Headers (see doc/X-OTRS-Headers.txt for more info).
Kernel/Config.pm:
# Job Name: 1-Match
# (block/ignore all spam email with From: noreply@)
$Self->{'PostMaster::PreFilterModule'}->{'1-Example'} = {
Module => 'Kernel::System::PostMaster::Filter::Example',
Match => {
From => 'noreply@',
},
Set => {
'X-OTRS-Ignore' => 'yes',
},
};
Format:
# --
# Kernel/System/PostMaster/Filter/Example.pm - a postmaster filter
# Copyright (C) 2005 Hans Mueller mail@example.com
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::System::PostMaster::Filter::Example;
use strict;
use vars qw($VERSION);
$VERSION = '$Revision: 1.21.2.1 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
sub new {
my $Type = shift;
my %Param = @_;
# allocate new hash for object
my $Self = {};
bless ($Self, $Type);
$Self->{Debug} = $Param{Debug} || 0;
# get needed opbjects
foreach (qw(ConfigObject LogObject DBObject)) {
$Self->{$_} = $Param{$_} || die "Got no $_!";
}
return $Self;
}
sub Run {
my $Self = shift;
my %Param = @_;
# get config options
my %Config = ();
my %Match = ();
my %Set = ();
if ($Param{JobConfig} && ref($Param{JobConfig}) eq 'HASH') {
%Config = %{$Param{JobConfig}};
if ($Config{Match}) {
%Match = %{$Config{Match}};
}
if ($Config{Set}) {
%Set = %{$Config{Set}};
}
}
# match 'Match => ???' stuff
my $Matched = '';
my $MatchedNot = 0;
foreach (sort keys %Match) {
if ($Param{GetParam}->{$_} && $Param{GetParam}->{$_} =~ /$Match{$_}/i) {
$Matched = $1 || '1';
if ($Self->{Debug} > 1) {
$Self->{LogObject}->Log(
Priority => 'debug',
Message => "'$Param{GetParam}->{$_}' =~ /$Match{$_}/i matched!",
);
}
}
else {
$MatchedNot = 1;
if ($Self->{Debug} > 1) {
$Self->{LogObject}->Log(
Priority => 'debug',
Message => "'$Param{GetParam}->{$_}' =~ /$Match{$_}/i matched NOT!",
);
}
}
}
# should I ignore the incoming mail?
if ($Matched && !$MatchedNot) {
foreach (keys %Set) {
if ($Set{$_} =~ /\[\*\*\*\]/i) {
$Set{$_} = $Matched;
}
$Param{GetParam}->{$_} = $Set{$_};
$Self->{LogObject}->Log(
Priority => 'notice',
Message => "Set param '$_' to '$Set{$_}' (Message-ID: $Param{GetParam}->{'Message-ID'}) ",
);
}
}
return 1;
}
1;
7.10.3. Ticket Menu Module
To add links in the ticket menu, just use ticket menu modules.
If you want to create your own ticket menu link, just create your own module. These modules are located under "Kernel/Output/HTML/TicketMenu*.pm". For default modules see the admin manual. You just need two functions: new() and Run():
The following example shows you how to show a lock or a unlock ticket link.
Kernel/Config.pm:
# for ticket zoom menu
$Self->{'Ticket::Frontend::MenuModule'}->{'100-Lock'} = {
'Action' => 'AgentTicketLock',
'Module' => 'Kernel::Output::HTML::TicketMenuLock',
'Name' => 'Lock'
};
# for ticket preview menu
$Self->{'Ticket::Frontend::PreMenuModule'}->{'100-Lock'} = {
Action => 'AgentTicketLock',
Module => 'Kernel::Output::HTML::TicketMenuLock',
Name => 'Lock'
};
Format:
# --
# Kernel/Output/HTML/TicketMenuLock.pm
# Copyright (C) 2005 Hans Mueller mail@example.com
# --
# $Id: module-format.xml,v 1.21.2.1 2007/10/17 06:24:05 tr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::Output::HTML::TicketMenuLock;
use strict;
use vars qw($VERSION);
$VERSION = '$Revision: 1.21.2.1 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
sub new {
my $Type = shift;
my %Param = @_;
# allocate new hash for object
my $Self = {};
bless ($Self, $Type);
# get needed objects
foreach (qw(ConfigObject LogObject DBObject LayoutObject UserID TicketObject)) {
$Self->{$_} = $Param{$_} || die "Got no $_!";
}
return $Self;
}
# --
sub Run {
my $Self = shift;
my %Param = @_;
# check needed stuff
if (!$Param{Ticket}) {
$Self->{LogObject}->Log(Priority => 'error', Message => "Need Ticket!");
return;
}
# check permission
if ($Self->{TicketObject}->LockIsTicketLocked(TicketID => $Param{TicketID})) {
my $AccessOk = $Self->{TicketObject}->OwnerCheck(
TicketID => $Param{TicketID},
OwnerID => $Self->{UserID},
);
if (!$AccessOk) {
return $Param{Counter};
}
}
$Self->{LayoutObject}->Block(
Name => 'Menu',
Data => { },
);
if ($Param{Counter}) {
$Self->{LayoutObject}->Block(
Name => 'MenuItemSplit',
Data => { },
);
}
if ($Param{Ticket}->{Lock} eq 'lock') {
$Self->{LayoutObject}->Block(
Name => 'MenuItem',
Data => {
%{$Param{Config}},
%{$Param{Ticket}},
%Param,
Name => 'Unlock',
Description => 'Unlock to give it back to the queue!',
Link => 'Action=AgentTicketLock&Subaction=Unlock&TicketID=$QData{"TicketID"}',
},
);
}
else {
$Self->{LayoutObject}->Block(
Name => 'MenuItem',
Data => {
%{$Param{Config}},
%Param,
Name => 'Lock',
Description => 'Lock it to work on it!',
Link => 'Action=AgentTicketLock&Subaction=Lock&TicketID=$QData{"TicketID"}',
},
);
}
$Param{Counter}++;
return $Param{Counter};
}
# --
1;
7.10.4. Ticket Event Module
Do do some actions on ticket events, just write your own ticket event module.
These modules are located under "Kernel/System/Ticket/Event/*.pm". For default modules see the admin manual. You just need two functions: new() and Run():
The following example shows you how to unlock a ticket after a move action.
Kernel/Config.pm:
$Self->{'Ticket::EventModulePost'}->{'99-ForceUnlockOnMove'} = {
Module => 'Kernel::System::Ticket::Event::ForceUnlock'
};
Format:
# --
# Kernel/System/Ticket/Event/ForceUnlook.pm - unlock ticket
# Copyright (C) 2005 Hans Mueller mail@example.com
# --
# $Id: module-format.xml,v 1.21.2.1 2007/10/17 06:24:05 tr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::System::Ticket::Event::ForceUnlock;
use strict;
use vars qw($VERSION);
$VERSION = '$Revision: 1.21.2.1 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
# --
sub new {
my $Type = shift;
my %Param = @_;
# allocate new hash for object
my $Self = {};
bless ($Self, $Type);
# get needed objects
foreach (qw(ConfigObject TicketObject LogObject)) {
$Self->{$_} = $Param{$_} || die "Got no $_!";
}
return $Self;
}
# --
sub Run {
my $Self = shift;
my %Param = @_;
# check needed stuff
foreach (qw(TicketID Event Config)) {
if (!$Param{$_}) {
$Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!");
return;
}
}
if ($Param{Event} eq 'MoveTicket') {
$Self->{TicketObject}->LockSet(
TicketID => $Param{TicketID},
Lock => 'unlock',
SendNoNotification => 1,
UserID => 1,
);
}
return 1;
}
# --
1;
Ticket Events for OTRS 2.0: TicketCreate, TicketDelete, TicketTitleUpdate, TicketUnlockTimeoutUpdate, TicketEscalationStartUpdate, MoveTicket, SetCustomerData, TicketFreeTextSet, TicketFreeTimeSet, TicketPendingTimeSet, LockSet, StateSet, OwnerSet, TicketResponsibleUpdate, PrioritySet, HistoryAdd, HistoryDelete, TicketAccountTime, TicketMerge, ArticleCreate, ArticleFreeTextSet, ArticleUpdate, ArticleSend, ArticleBounce, SendAgentNotification, SendCustomerNotification, SendAutoResponse, ArticleFlagSet;
Ticket Events for OTRS 2.1 and higher: TicketCreate, TicketDelete, TicketTitleUpdate, TicketUnlockTimeoutUpdate, TicketEscalationStartUpdate, TicketQueueUpdate (MoveTicket), TicketCustomerUpdate (SetCustomerData), TicketFreeTextUpdate (TicketFreeTextSet), TicketFreeTimeUpdate (TicketFreeTimeSet), TicketPendingTimeUpdate (TicketPendingTimeSet), TicketLockUpdate (LockSet), TicketStateUpdate (StateSet), TicketOwnerUpdate (OwnerSet), TicketResponsibleUpdate, TicketPriorityUpdate (PrioritySet), HistoryAdd, HistoryDelete, TicketAccountTime, TicketMerge, ArticleCreate, ArticleFreeTextUpdate (ArticleFreeTextSet), ArticleUpdate, ArticleSend, ArticleBounce, ArticleAgentNotification, (SendAgentNotification), ArticleCustomerNotification (SendCustomerNotification), ArticleAutoResponse (SendAutoResponse), ArticleFlagSet;
7.10.5. More Modules
The Agent Ticket Permission Modules (Kernel/System/Ticket/Permission/) contain functions to verify an agent's authorisation to access a ticket.
The Customer Ticket Permission Modules (Kernel/System/Ticket/CustomerPermission/) contain functions to verify a customer's authorisation to access a ticket.
The Article Module (Kernel/System/Ticket/Article.pm) facilitates the readout and generating of ticket articles.
More modules and their descriptions are listed under http://dev.otrs.org/

