NAME

OTRS::ForwardQueue - Forwards the contents of an OTRS queue to a given email address.

VERSION

version 0.13

SYNOPSIS

    use OTRS::ForwardQueue;

    %query = (
      Queues => ['MyQueue'],
      States => ['new', 'open'],
      Locks => ['unlock'],
      UserID => 1,
    );

    %options = (
      ForwardTo => 'nobody@example.org',
      TempDir => '/tmp',
      HistoryComment => 'Forward to other request system',
      SMTP => 1,
      SMTPServer => 'smtp.example.org',
      NotifyCustomer => 1,
      NotifyCustomerTemplate => 'notify_customer.tt',
      TemplatesPath => '/usr/local/templates',
      Debug => 1,
    );

    my $fq = OTRS::ForwardQueue->new('query' => \%query, 'options' => \%options);

    $fq->process_queue();

DESCRIPTION

This module queries the Open Technology Real Services (OTRS) ticket management system for tickets matching the query provided and then forwards these tickets to an email address, closing them in OTRS.

The following functions are provided:

new(\%query, \%options)

Produced automatically by Moose, this is the constructor for the class.

\%query

Reference to a hash which contains the query parameters. This takes the same key/value pairs as the TicketSearch function of Kernel::System::TicketSearch, except that the Result value is always set to 'ARRAY'.

\%options

Required list of options which affect how the queue is processed.

HistoryComment (required): The comment left in the history of the ticket when it is forwarded to anther system.
TempDir (optional): Override the temporary directory used by the OTRS cache. Probably needs to be set if you are not running the module as the web server user (e.g. apache). If you get errors about file permissions, try setting this to '/tmp'.
ForwardTo (required): The email address to forward tickets to.
DisableLocking (optional): Set to 1 to disable locking of forwarded tickets. Default behaviour is to lock tickets.
DisableHistory (optional): Set to 1 to disable leaving a comment in the history (effectively makes HistoryComment redundant). Default behaviour is to add a comment.
DisableClosing (optional): Set to 1 to disable closing the ticket after forwarding. Default behaviour is to mark ticket as 'closed successful'.
DisableEmail (optional): Set to 1 to disable sending any emails, which effectively prevents forwarding of tickets. Default behaviour is to send email. Included as an option to allow module users to test their code before sending out emails.
SMTP (optional): Set to 1 to use an SMTP server to send email, instead of the local MTA.
SMTPServer (optional): Host name or IP address of the SMTP server to use. Only effective if SMTP is set to 1.
NotifyCustomer (optional): Set to 1 to create a new article on the ticket and notify the customer that it has been forwarded.
NotifyCustomerTemplate (optional): Relative filename to template for customer notification. Required if NotifyCustomer is set to 1.
TemplatesPath (optional): Absolute path to template directory. Required if NotifyCustomerTemplate is set.
Debug (optional): Set to 1 to print extra debugging information, such as the IDs of forwarded tickets.
process_queue()

Processes the queue based on the options passed in the constructor.

DEPENDENCIES

Perl version 5.14 or higher is required. You may be able to use the module with older versions of Perl, but this is neither tested nor supported.

This module requires the following modules:

Although some of the above modules are used for optional features, all the dependencies must be installed as this module will attempt to import all of them.

You must also have the OTRS source installed and available via @INC. This module has been tested with OTRS 3.2.10 and 3.3.9.

RUNNING AS A CRON JOB

Running a script which uses this module as a cron job may require some additional tweaks. The easiest way is to create a small wrapper script to set the various library paths correctly, such as the one below:

    #!/bin/bash
    
    # Set this to the absolute path to your OTRS install, so those
    # modules can be loaded
    FQ_OTRS_LIB="-I/path/to/otrs"
    
    # Comment out this line if you are not using local::lib
    FQ_LOCAL_LIB="-I$HOME/perl5/lib/perl5"
    
    # Change this to the path of your script
    /usr/bin/perl "$FQ_OTRS_LIB" "$FQ_LOCAL_LIB" /path/to/script.pl

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs through the Github issue system:

https://github.com/pwaring/OTRS-ForwardQueue/issues

AUTHOR

Paul Waring <paul.waring@manchester.ac.uk>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by University of Manchester.

This is free software, licensed under:

  The GNU Affero General Public License, Version 3, November 2007