Kernel::System::Calendar - calendar lib
All calendar functions.
create an object. Do not use it directly, instead use:
use Kernel::System::ObjectManager; local $Kernel::OM = Kernel::System::ObjectManager->new(); my $CalendarObject = $Kernel::OM->Get('Kernel::System::Calendar');
creates a new calendar for given user.
my %Calendar = $CalendarObject->CalendarCreate( CalendarName => 'Meetings', # (required) Personal calendar name GroupID => 3, # (required) GroupID Color => '#FF7700', # (required) Color in hexadecimal RGB notation UserID => 4, # (required) UserID TicketAppointments => [ # (optional) Ticket appointments, array ref of hashes { StartDate => 'FirstResponse', EndDate => 'Plus_5', QueueID => [ 2 ], SearchParams => { Title => 'This is a title', Types => 'This is a type', }, }, ], ValidID => 1, # (optional) Default is 1. );
returns Calendar hash if successful: %Calendar = ( CalendarID => 2, GroupID => 3, CalendarName => 'Meetings', CreateTime => '2016-01-01 08:00:00', CreateBy => 4, ChangeTime => '2016-01-01 08:00:00', ChangeBy => 4, ValidID => 1, );
Events: CalendarCreate
Get calendar by name or id.
my %Calendar = $CalendarObject->CalendarGet( CalendarName => 'Meetings', # (required) Calendar name # or CalendarID => 4, # (required) CalendarID UserID => 2, # (optional) UserID - System will check if user has access to calendar if provided );
Returns Calendar data:
%Calendar = ( CalendarID => 2, GroupID => 3, CalendarName => 'Meetings', Color => '#FF7700', TicketAppointments => [ { StartDate => 'FirstResponse', EndDate => 'Plus_5', QueueID => [ 2 ], SearchParams => { Title => 'This is a title', Types => 'This is a type', }, }, ], CreateTime => '2016-01-01 08:00:00', CreateBy => 1, ChangeTime => '2016-01-01 08:00:00', ChangeBy => 1, ValidID => 1, );
Get calendar list.
my @Result = $CalendarObject->CalendarList( UserID => 4, # (optional) For permission check Permission => 'rw', # (optional) Required permission (default ro) ValidID => 1, # (optional) Default 0. # 0 - All states # 1 - All valid # 2 - All invalid # 3 - All temporary invalid );
Returns:
@Result = [ { CalendarID => 2, GroupID => 3, CalendarName => 'Meetings', Color => '#FF7700', CreateTime => '2016-01-01 08:00:00', CreateBy => 3, ChangeTime => '2016-01-01 08:00:00', ChangeBy => 3, ValidID => 1, }, { CalendarID => 3, GroupID => 3, CalendarName => 'Customer presentations', Color => '#BB00BB', CreateTime => '2016-01-01 08:00:00', CreateBy => 3, ChangeTime => '2016-01-01 08:00:00', ChangeBy => 3, ValidID => 0, }, ... ];
updates an existing calendar.
my $Success = $CalendarObject->CalendarUpdate( CalendarID => 1, # (required) CalendarID GroupID => 2, # (required) Calendar group CalendarName => 'Meetings', # (required) Personal calendar name Color => '#FF9900', # (required) Color in hexadecimal RGB notation UserID => 4, # (required) UserID (who made update) ValidID => 1, # (required) ValidID TicketAppointments => [ # (optional) Ticket appointments, array ref of hashes { StartDate => 'FirstResponse', EndDate => 'Plus_5', QueueID => [ 2 ], SearchParams => { Title => 'This is a title', Types => 'This is a type', }, }, ], );
Returns 1 if successful.
Events: CalendarUpdate
import a calendar
my $Success = $CalendarObject->CalendarImport( Data => { CalendarData => { CalendarID => 2, GroupID => 3, CalendarName => 'Meetings', Color => '#FF7700', ValidID => 1, }, AppointmentData => { { AppointmentID => 2, ParentID => 1, CalendarID => 1, UniqueID => '20160101T160000-71E386@localhost', ... }, ... }, }, OverwriteExistingEntities => 0, # (optional) Overwrite existing calendar and appointments, default: 0 # Calendar with same name will be overwritten # Appointments with same UniqueID in existing calendar will be overwritten UserID => 1, );
returns 1 if successful
export a calendar
my %Data = $CalendarObject->CalendarExport( CalendarID => 2, UserID => 1, }
returns calendar hash with data:
%Data = ( CalendarData => { CalendarID => 2, GroupID => 3, CalendarName => 'Meetings', Color => '#FF7700', ValidID => 1, }, AppointmentData => ( { AppointmentID => 2, ParentID => 1, CalendarID => 1, UniqueID => '20160101T160000-71E386@localhost', ... }, ... ), );
Get permission level for given CalendarID and UserID.
my $Permission = $CalendarObject->CalendarPermissionGet( CalendarID => 1, # (required) CalendarID UserID => 4, # (required) UserID );
Returns:
$Permission = 'rw'; # 'ro', 'rw', ...
Handle the automatic ticket appointments for the ticket.
$CalendarObject->TicketAppointmentProcessTicket( TicketID => 1, );
This method does not have return value.
Handle the automatic ticket appointments for the calendar.
my %Result = $CalendarObject->TicketAppointmentProcessCalendar( CalendarID => 1, );
Returns log of processed tickets and rules:
%Result = ( Process => [ { TicketID => 1, RuleID => '9bb20ea035e7a9930652a9d82d00c725', Success => 1, }, { TicketID => 2, RuleID => '9bb20ea035e7a9930652a9d82d00c725', Success => 1, }, ], Cleanup => [ { RuleID => 'b272a035ed82d65a927a99300e00c9b5', Success => 1, }, ], );
Process the ticket appointment rule and create, update or delete appointment if necessary.
my $Success = $CalendarObject->TicketAppointmentProcessRule( CalendarID => 1, Config => { DynamicField_TestDate => { Module => 'Kernel::System::Calendar::Ticket::DynamicField', }, ... }, Rule => { StartDate => 'DynamicField_TestDate', EndDate => 'Plus_5', QueueID => [ 2 ], RuleID => '9bb20ea035e7a9930652a9d82d00c725', SearchParams => { Title => 'Welcome*', }, }, TicketID => 1, );
Returns 1 if successful.
Updates the ticket with data from ticket appointment.
$CalendarObject->TicketAppointmentUpdateTicket( AppointmentID => 1, TicketID => 1, );
This method does not have return value.
get ticket id of a ticket appointment.
my $TicketID = $CalendarObject->TicketAppointmentTicketID( AppointmentID => 1, );
returns appointment ID if successful.
get used ticket appointment rules for specific calendar.
my @RuleIDs = $CalendarObject->TicketAppointmentRuleIDsGet( CalendarID => 1, TicketID => 1, # (optional) Return rules used only for specific ticket );
returns array of rule IDs if found.
get ticket appointment rule.
my $Rule = $CalendarObject->TicketAppointmentRuleGet( CalendarID => 1, RuleID => '9bb20ea035e7a9930652a9d82d00c725', );
returns rule hash:
get defined ticket appointment types from config.
my %TicketAppointmentTypes = $CalendarObject->TicketAppointmentTypesGet();
returns hash of appointment types:
%TicketAppointmentTypes = ();
delete ticket appointment(s).
my $Success = $CalendarObject->TicketAppointmentDelete( CalendarID => 1, # (required) CalendarID RuleID => '9bb20ea035e7a9930652a9d82d00c725', # (required) RuleID # or TicketID => 1, # (required) Ticket ID AppointmentID => 1, # (optional) Appointment ID is known );
returns 1 if successful.
get access token for the calendar.
my $Token = $CalendarObject->GetAccessToken( CalendarID => 1, # (required) CalendarID UserLogin => 'agent-1', # (required) User login );
Returns:
$Token = 'rw';
Returns best text color for supplied background, based on luminosity difference algorithm.
my $BestTextColor = $CalendarObject->GetTextColor( Background => '#FFF', # (required) must be in valid hexadecimal RGB notation );
Returns:
$BestTextColor = '#000';
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.