Kernel::System::NotificationEvent - to manage the notifications
All functions to manage the notification and the notification jobs.
Don't use the constructor directly, use the ObjectManager instead:
my $NotificationEventObject = $Kernel::OM->Get('Kernel::System::NotificationEvent');
returns a hash of all notifications
my %List = $NotificationEventObject->NotificationList( Type => 'Ticket', # type of notifications; default: 'Ticket' Details => 1, # include notification detailed data. possible (0|1) # ; default: 0 All => 1, # optional: if given all notification types will be returned, even if type is given (possible: 0|1) );
returns a hash of the notification data
my %Notification = $NotificationEventObject->NotificationGet( Name => 'NotificationName', ); my %Notification = $NotificationEventObject->NotificationGet( ID => 1, );
Returns:
%Notification = ( ID => 123, Name => 'Agent::Move', Data => { Events => [ 'TicketQueueUpdate' ], ... Queue => [ 'SomeQueue' ], }, Message => { en => { Subject => 'Hello', Body => 'Hello World', ContentType => 'text/plain', }, de => { Subject => 'Hallo', Body => 'Hallo Welt', ContentType => 'text/plain', }, }, Comment => 'An optional comment', ValidID => 1, CreateTime => '2010-10-27 20:15:00', CreateBy => 2, ChangeTime => '2010-10-27 20:15:00', ChangeBy => 1, UserID => 3, );
adds a new notification to the database
my $ID = $NotificationEventObject->NotificationAdd( Name => 'Agent::OwnerUpdate', Data => { Events => [ 'TicketQueueUpdate' ], ... Queue => [ 'SomeQueue' ], }, Message => { en => { Subject => 'Hello', Body => 'Hello World', ContentType => 'text/plain', }, de => { Subject => 'Hallo', Body => 'Hallo Welt', ContentType => 'text/plain', }, }, Comment => 'An optional comment', # (optional) ValidID => 1, UserID => 123, );
update a notification in database
my $Ok = $NotificationEventObject->NotificationUpdate( ID => 123, Name => 'Agent::OwnerUpdate', Data => { Events => [ 'TicketQueueUpdate' ], ... Queue => [ 'SomeQueue' ], }, Message => { en => { Subject => 'Hello', Body => 'Hello World', ContentType => 'text/plain', }, de => { Subject => 'Hallo', Body => 'Hallo Welt', ContentType => 'text/plain', }, }, Comment => 'An optional comment', # (optional) ValidID => 1, UserID => 123, );
deletes an notification from the database
$NotificationEventObject->NotificationDelete( ID => 1, UserID => 123, );
returns array of notification affected by event
my @IDs = $NotificationEventObject->NotificationEventCheck( Event => 'ArticleCreate', );
import an Notification YAML file/content
my $NotificationImport = $NotificationEventObject->NotificationImport( Content => $YAMLContent, # mandatory, YAML format OverwriteExistingNotifications => 0, # 0 || 1 UserID => 1, # mandatory );
Returns:
$NotificationImport = { Success => 1, # 1 if success or undef if operation could not # be performed Message => 'The Message to show.', # error message AddedNotifications => 'Notification1, Notification2', # list of Notifications correctly added UpdatedNotifications => 'Notification3, Notification4', # list of Notifications correctly updated NotificationErrors => 'Notification5', # list of Notifications that could not be added or updated };
Check if body has a proper length depending on DB type.
my $Ok = $NotificationEventObject->NotificationBodyCheck( Content => $BodyContent, # mandatory UserID => 1, # mandatory );
This software is part of the OTRS project (https://otrs.org/).
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 https://www.gnu.org/licenses/gpl-3.0.txt.