Chapter 25. Developer's guide - Writing OTRS Modules

Table of Contents
AgentInterface Notification Modules
CustomerInterface Notification Modules
Ticket Number Generator
Agent Auth Modules
Customer Auth Modules
Customer User Modules
PostMaster Filter Modules
Generic Agent Modules
Agent Ticket Permission Modules
Customer Ticket Permission Modules

This chapter will show you more details about writing common OTRS Modules.

AgentInterface Notification Modules

With agent notification modules you can inform agents about new infos. A normal navigation looks like that:

Example of a simple notification module, save it under Kernel/Output/HTML/NotificationMotd.pm.
# --
# Kernel/Output/HTML/NotificationMotd.pm - message of the day  
# Copyright (C) 2003 Hans Mueller mail@example.com
# --
# $Id: developer-guide-custom-modules.sgml,v 1.6 2004/04/23 08:21:17 martin 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::NotificationMotd;

use strict;

# --
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)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }
    return $Self;
}
# --
sub Run {
    my $Self = shift;
    my %Param = @_;
    return $Self->{LayoutObject}->Notify(Info => 'Some daily news!');
}
# --

1;
To use this module, add the following to the Kernel/Config.pm and restart your webserver (if you use mod_perl).

    # Frontend::NotifyModule - module name (50-Motd)
    $Self->{'Frontend::NotifyModule'}->{'50-Motd'} = {
        Module => 'Kernel::Output::HTML::NotificationMotd',
    };
The result will be a notification box in your agent interface:

Normally you want to put more intelligence into your notification module. This kind of modules are useful for escalation infos.

Default notification modules are (Kernel/Config.pm):

    # agent interface notification module to check the used charset
    $Self->{'Frontend::NotifyModule'}->{'1-CharsetCheck'} = {
        Module => 'Kernel::Output::HTML::NotificationCharsetCheck',
    };

    # agent interface notification module to check the admin user id
    # (don't work with user id 1 notification)
    $Self->{'Frontend::NotifyModule'}->{'2-UID-Check'} = {
        Module => 'Kernel::Output::HTML::NotificationUIDCheck',
    };

    # show online agents
    $Self->{'Frontend::NotifyModule'}->{'3-ShowAgentOnline'} = {
        Module => 'Kernel::Output::HTML::NotificationAgentOnline',
    };
    # show online customers
    $Self->{'Frontend::NotifyModule'}->{'4-ShowCustomerOnline'} = {
        Module => 'Kernel::Output::HTML::NotificationCustomerOnline',
    };