NAME
Kernel::System::NotificationView – to manage the notification view entries
DESCRIPTION
All functions to manage the notification event list entries.
PUBLIC INTERFACE
BUILD()
Moose constructor method, that is executed on instantiation
of the object.
NotificationAdd()
adds a new notification to the database
my $NotificationID = $NotificationViewObject->NotificationAdd(
Name => 'some notification name', # (required)
Comment => 'some notification comments', # (optional)
Subject => 'some subject', # (required)
Body => 'some body', # (required)
ObjectType => 'some object type', # (required) e.g. Ticket
ObjectID => 123, # (required)
ObjectReference => '54321', # (optional) usefull (like the TicketNumber)
UserID => 123, # (required)
UserType => 'Agent', # (required) 'Agent' or 'Customer'
);
returns:
$NotificationID = 123 # or false in case of a failure
NotificationGet()
returns the notification data
my %Notification = $NotificationViewObject->NotificationGet(
NotificationID => 123, # (required)
);
returns:
%Notification = (
NotificationID => 123,
Name => 'some notification name',
Comment => 'some notification comments',
Subject => 'some notification subject',
Body => 'some notification body',
ObjectType => 'some object type',
ObjectID => 123,
ObjectReference => '54321',
Seen => 1, # 1 or 0
CreateTime => '2015-05-07 12:27:00',
UserID => 123,
UserType => 'Agent' # (Agent|Customer)
)
NotificationDelete()
deletes notifications from the database
my $Success = $NotificationViewObject->NotificationDelete(
NotificationID => 123,
);
or
my $Success = $NotificationViewObject->NotificationDelete(
UserID => 123,
UserType => 'Agent',
ObjectType => 'Ticket',
ObjectID => 123,
);
or
my $Success = $NotificationViewObject->NotificationDelete(
UserID => 123,
UserType => 'Agent',
);
returns
$Success = 1; # or false in case of a failure
NotificationList()
returns a list of notifications (filtered by a user id if given)
my %NotificationList = $NotificationViewObject->NotificationList(
UserID => 123, # (optional)
UserType => 'Agent', # (required if UserID is present)
ObjectType => 'Ticket' # (optional)
);
returns
%NotificationList = (
123 => 'Notification 1',
456 => 'Notification 2'.
);
NotificationListGet()
returns a list of notifications and it's details for certain user (filtered by ObjectType)
my %NotificationList = $NotificationViewObject->NotificationListGet(
UserID => 123, # (required)
UserType => 'Agent', # (required) 'Agent' or 'Customer'
ObjectType => 'Ticket', # (optional)
Seen => 1, # (optional) 0, 1 or undef
);
returns
%NotificationList = (
123 => {
NotificationID => 123,
Name => 'Notification 1,
Comment => 'some notification comment'
# ...
}
456 => {
NotificationID => 456,
Name => 'Notification 2,
Comment => 'some notification comment'
# ...
}
);
NotificationSeenSet()
mark a notification as seen or unseen
my $Success = $NotificationViewObject->NotificationSeenSet(
NotificationID => 123, # (required)
Seen => 1, # (optional) 1 or 0
UserID => 123, # (required)
UserType => 'Agent', # (required) 'Agent' or 'Customer'
);
returns
Success = 1; # or false in case of an error
NotificationSearch()
To find sent event based notifications in your system.
my @NotificationIDs = $NotificationViewObject->NotificationSearch(
# result (required)
Result => 'ARRAY' || 'HASH' || 'COUNT' || 'CHANGE',
# result limit
Limit => 100,
# notification name (optional) as STRING or as ARRAYREF
Name => '%SomeName%',
Name => ['%SomeName%', '%SomeOther%'],
# notification subject (optional) as STRING or as ARRAYREF
Subject => '%SomeText%',
Subject => ['%SomeTest1%', '%SomeTest2%'],
ObjectTypes => ['Ticket', 'Other'],
ObjectReferences => ['123', '456'],
ObjectIDs => [1, 42, 512],
UserIDs => [1, 12, 455, 32]
UserTypes => ['Agent', 'Customer']
Seen => [1, 0],
# OrderBy and SortBy (optional)
OrderBy => 'Down', # Down|Up
SortBy => 'Age', # Name|Age|CreateTime|ChangeTime|Subject|ObjectType|ObjectID|ID
# OrderBy and SortBy as ARRAY for sub sorting (optional)
OrderBy => ['Down', 'Up'],
SortBy => ['Priority', 'Age'],
# CacheTTL, cache search result in seconds (optional)
CacheTTL => 60 * 15,
);
Returns:
Result: 'ARRAY'
@NotificationIDs = ( 1, 2, 3 );
Result: 'HASH'
%NotificationIDs = (
1 => 'SomeName',
2 => 'SomeOther',
3 => 'SomeOther2',
);
Result: 'COUNT'
$Count = 123;
NameFilterGet()
get a list of notification event names
my @NotificationNames = $NotificationViewObject->NameFilterGet(
UserID => 123,
);
Returns:
@NotificationNames = [
'Notification1',
'Notification2',
];
ObjectReferenceFilterGet()
get a list of notification event object references.
my @Result = $NotificationViewObject->ObjectReferenceFilterGet();
Returns:
@Result = (
'1978348789',
'8788987223',
);
PRIVATE FUNCTIONS
_InConditionGet()
internal function to create an
AND table.column IN (values)
condition string from an array.
my $SQLPart = $NotificationViewObject->_InConditionGet(
TableColumn => 'table.column',
IDRef => $ArrayRef,
);