NAME
Kernel::System::Ticket::Article::Backend::Base – base class for article backends
DESCRIPTION
This is a base class for article backends and should not be instantiated directly.
package Kernel::System::Ticket::Article::Backend::MyBackend;
use strict;
use warnings;
use parent qw(Kernel::System::Ticket::Article::Backend::Base);
# methods go here
PUBLIC INTERFACE
new()
Do not instantiate this class, instead use the real article backend classes. Also, don't use the constructor directly, use the ObjectManager instead:
my $ArticleBackendObject = $Kernel::OM->Get('Kernel::System::Ticket::Article::Backend::MyBackend');
ChannelNameGet()
Returns name of the communication channel used by the article backend. Used internally. Override this method in your backend class.
my $ChannelName = $ArticleBackendObject->ChannelNameGet();
$ChannelName = 'MyBackend';
DocumentTypeGet()
Returns name of the document type for the article backend. Used internally. Override this method in your backend class.
my $ChannelName = $ArticleBackendObject->DocumentTypeGet();
$DocumentSearchDriverName = 'DocumentSearchDriver';
ArticleHasHTMLContent()
Returns 1 if article has HTML content.
my $ArticleHasHTMLContent = $ArticleBackendObject->ArticleHasHTMLContent(
TicketID => 1,
ArticleID => 2,
UserID => 1,
);
Result:
$ArticleHasHTMLContent = 1; # or 0
ChannelIDGet()
Returns registered communication channel ID. Same for all article backends, don't override this particular method. In case of invalid article backend, this method will return false value.
my $ChannelID = $ArticleBackendObject->ChannelIDGet();
$ChannelID = 1;
ArticleCreateTimeSet()
Set CreateTime data of article.
my $Success = $ArticleBackendObject->ArticleCreateTimeSet(
CreateTime => '2000-01-01 12:34:56',
TicketID => 123,
ArticleID => 123,
UserID => 23,
);
ArticleChangeTimeSet()
Set ChangeTime data of article.
my $Success = $ArticleBackendObject->ArticleChangeTimeSet(
ChangeTime => '2000-01-01 12:34:56',
TicketID => 123,
ArticleID => 123,
UserID => 23,
);
ArticleCreate()
Create an article. Override this method in your class.
my $ArticleID = $ArticleBackendObject->ArticleCreate(
TicketID => 123,
SenderType => 'agent', # agent|system|customer
IsVisibleForCustomer => 1,
UserID => 123,
# Backend specific parameters:
# From => 'Some Agent <email@example.com>',
# To => 'Some Customer A <customer-a@example.com>',
# Subject => 'some short description',
# ...
);
Events: ArticleCreate
ArticleUpdate()
Update an article. Override this method in your class.
my $Success = $ArticleBackendObject->ArticleUpdate(
TicketID => 123,
ArticleID => 123,
Key => 'Body',
Value => 'New Body',
UserID => 123,
);
Events: ArticleUpdate
ArticleGet()
Returns article data. Override this method in your class.
my %Article = $ArticleBackendObject->ArticleGet(
TicketID => 123,
ArticleID => 123,
DynamicFields => 1,
# Backend specific parameters:
# RealNames => 1,
);
ArticleDelete()
Delete an article. Override this method in your class.
my $Success = $ArticleBackendObject->ArticleDelete(
TicketID => 123,
ArticleID => 123,
UserID => 123,
);
BackendSearchableFieldsGet()
Get article attachment index as hash.
my %Index = $ArticleBackendObject->BackendSearchableFieldsGet();
Returns:
my %BackendSearchableFieldsGet = {
From => 'from',
To => 'to',
Cc => 'cc',
Subject => 'subject',
Body => 'body',
};
ArticleSearchableContentGet()
Get article attachment index as hash.
my %Index = $ArticleBackendObject->ArticleSearchableContentGet(
TicketID => 123, # (required)
ArticleID => 123, # (required)
DynamicFields => 1, # (optional) To include the dynamic field values for this article on the return structure.
RealNames => 1, # (optional) To include the From/To/Cc fields with real names.
UserID => 123, # (required)
);
Returns:
my %ArticleSearchData = [
{
'From' => 'Test User1 <testuser1@example.com>',
'To' => 'Test User2 <testuser2@example.com>',
'Cc' => 'Test User3 <testuser3@example.com>',
'Subject' => 'This is a test subject!',
'Body' => 'This is a body text!',
...
},
];
TransmissionStatus()
Returns current transmission status of the article, by modifying passed article reference.
$ArticleBackendObject->TransmissionStatus(
Article => {
...
},
);
Returns 1 if successful.
Modifies passed article reference:
Article => {
TransmissionStatus => {
ArticleID => 123,
MessageID => 456,
Message => 'Descriptive message of last communication', # only in case of failed status
CreateTime => '2017-01-01 12:34:56',
Status => [Processing|Failed],
Attempts => 1, # only in case of processing status
DueTime => '2017-01-02 12:34:56', # only in case of processing status
},
}
PRIVATE FUNCTIONS
Use following functions from backends only.
_MetaArticleCreate()
Create a new article.
my $ArticleID = $Self->_MetaArticleCreate(
TicketID => 123,
SenderType => 'agent', # agent|system|customer
IsVisibleForCustomer => 0,
CommunicationChannel => 'Email',
UserID => 1,
);
Alternatively, you can pass in IDs too:
my $ArticleID = $Self->_MetaArticleCreate(
TicketID => 123,
SenderTypeID => 1,
IsVisibleForCustomer => 0,
CommunicationChannelID => 2,
UserID => 1,
);
_MetaArticleUpdate()
Update an article.
Note: Keys SenderType
, SenderTypeID
and IsVisibleForCustomer
are implemented.
my $Success = $Self->_MetaArticleUpdate(
TicketID => 123, # (required)
ArticleID => 123, # (required)
Key => 'IsVisibleForCustomer', # (optional) If not provided, only ChangeBy and ChangeTime will be updated.
Value => 1, # (optional)
UserID => 123, # (required)
);
my $Success = $Self->_MetaArticleUpdate(
TicketID => 123,
ArticleID => 123,
Key => 'SenderType',
Value => 'agent',
UserID => 123,
);
Events: MetaArticleUpdate
_MetaArticleGet()
Get article meta data.
my %Article = $Self->_MetaArticleGet(
ArticleID => 42,
TicketID => 23,
);
Returns:
%Article = (
ArticleID => 1,
TicketID => 2,
CommunicationChannelID => 1,
SenderTypeID => 1,
IsVisibleForCustomer => 0,
CreateTime => ...,
CreateBy => ...,
ChangeTime => ...,
ChangeBy => ...,
);
_MetaArticleDelete()
Delete an article. This must be called after all backend data has been deleted.
my $Success = $Self->_MetaArticleDelete(
ArticleID => 123,
UserID => 123,
TicketID => 123,
);
_MetaArticleDynamicFieldsGet()
Returns article content with dynamic fields.
my %Data = $Self->_MetaArticleDynamicFieldsGet(
Data => { # (required) article data
TicketID => 1,
ArticleID => 1,
From => 'agent@mail.org',
To => 'customer@mail.org',
...
},
);
Returns: %Data = ( TicketID => 1, ArticleID => 1, From => 'agent@mail.org', To => 'customer@mail.org', …, DynamicField_A => 'Value A', … );