Generic Agent Modules

See also chapter "GenericAgent".

This module will notify the current ticket owner.

A example of a simple generic agent module, save it under Kernel/System/GenericAgent/Simple.pm. You just need 2 functions, new() and Run(). Run() will be get the ticket id:
# --
# Kernel/System/GenericAgent/Simple.pm - generic agent notifications
# Copyright (C) 2001-2004 Martin Edenhofer <martin+code otrs.org>
# --
# $Id: developer-guide-custom-modules.sgml,v 1.5 2004/02/08 22:26:45 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::System::GenericAgent::Simple;
    
use strict;
use Kernel::System::User;
use Kernel::System::Email;
    
use vars qw(@ISA $VERSION);
$VERSION = '$Revision: 1.5 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;

# --
sub new {
    my $Type = shift;
    my %Param = @_;

    # allocate new hash for object
    my $Self = {};
    bless ($Self, $Type);

    # check needed objects
    foreach (qw(DBObject ConfigObject LogObject TicketObject)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }

    $Self->{UserObject} = Kernel::System::User->new(%Param);
    $Self->{EmailObject} = Kernel::System::Email->new(%Param);

    return $Self;
}
# --
sub Run {
    my $Self = shift;
    my %Param = @_;

    my %Ticket = $Self->{TicketObject}->GetTicket(%Param);

    my %User = $Self->{UserObject}->GetUserData(UserID => $Ticket{UserID});
    if ($User{UserEmail}) {
        $Self->{EmailObject}->Send(
                 To => $User{UserEmail},
                Subject => "[$Ticket{TicketNumber}] Ticket Notification!",
                Body => "Hi $User{Firstname}, some info ... about $Ticket{'TicketNumber'}".
                Loop => 1,
        );
    }

    return 1;
}
# --
1;