Kernel::System::Calendar

NAME

Kernel::System::Calendar – calendar lib

DESCRIPTION

All calendar functions.

PUBLIC INTERFACE

new()

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');

CalendarCreate()

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',
                },
            },
        ],

        Config => {                             # (optional) Calendar config, e.g. dynamic fields
            DynamicFields => {
                Name1 => 1|2|3,                     # (1 - shown, 2 - shown + required, 3 - Use form config)
                Name2 => 1|2|3,                     # (1 - shown, 2 - shown + required, 3 - Use form config)
                Name3 => 1|2|3,                     # (1 - shown, 2 - shown + required, 3 - Use form config)
            },
            AdditionalDescription => 'abc',
            DefaultValues => {
                Title       => 'a',
                Description => 'a',
                Location    => 'b',
            },
        },

        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

CalendarGet()

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',
                },
            },
        ],
        Config => {
            DynamicFields => {
                Name1 => 1,
                Name2 => 1,
                Name3 => 1,
            },
            AdditionalDescription => 'abc',
            DefaultValues => {
                Title       => 'a',
                Description => 'a',
                Location    => 'b',
            },
        },
        CreateTime => '2016-01-01 08:00:00',
        CreateBy   => 1,
        ChangeTime => '2016-01-01 08:00:00',
        ChangeBy   => 1,
        ValidID    => 1,
    );

CalendarList()

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
        Valid      => 1,            # (optional) Get all valid calendars
    );

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,
            Config       => {
                DynamicFields => {
                    Name1 => 1,
                    Name2 => 1,
                    Name3 => 1,
                },
                AdditionalDescription => 'abc',
                DefaultValues => {
                    Title       => 'a',
                    Description => 'a',
                    Location    => 'b',
                },
            },
        },
        {
            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,
            Config       => {
                DynamicFields => {
                    Name1 => 1,
                    Name2 => 1,
                    Name3 => 1,
                },
                AdditionalDescription => 'abc',
                DefaultValues => {
                    Title       => 'a',
                    Description => 'a',
                    Location    => 'b',
                },
            },
        },
        ...
    ];

CalendarUpdate()

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',
                },
            },
        ],

        Config => {                             # (optional) Calendar config, e.g. dynamic fields
            DynamicFields => {
                Name1 => 1|2,                     # (1 - shown, 2 - shown + required)
                Name2 => 1|2,                     # (1 - shown, 2 - shown + required)
                Name3 => 1|2,                     # (1 - shown, 2 - shown + required)
            },
            AdditionalDescription => 'abc',
            DefaultValues => {
                Title       => 'a',
                Description => 'a',
                Location    => 'b',
            },
        },
    );

Returns 1 if successful.

Events: CalendarUpdate

CalendarImport()

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

CalendarExport()

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',
                ...
            },
            ...
        ),
    );

CalendarPermissionGet()

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', ...

TicketAppointmentProcessTicket()

Handle the automatic ticket appointments for the ticket.

    $CalendarObject->TicketAppointmentProcessTicket(
        TicketID => 1,
    );

This method does not have return value.

TicketAppointmentProcessCalendar()

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,
            },
        ],
    );

TicketAppointmentProcessRule()

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::DynamicFieldLegacy',
            },
            ...
        },
        Rule => {
            StartDate => 'DynamicField_TestDate',
            EndDate   => 'Plus_5',
            QueueID   => [ 2 ],
            RuleID    => '9bb20ea035e7a9930652a9d82d00c725',
            SearchParams => {
                Title => 'Welcome*',
            },
        },
        TicketID => 1,
    );

Returns 1 if successful.

TicketAppointmentUpdateTicket()

Updates the ticket with data from ticket appointment.

    $CalendarObject->TicketAppointmentUpdateTicket(
        AppointmentID => 1,
        TicketID      => 1,
    );

This method does not have return value.

TicketAppointmentTicketID()

get ticket id of a ticket appointment.

    my $TicketID = $CalendarObject->TicketAppointmentTicketID(
        AppointmentID => 1,
    );

returns appointment ID if successful.

TicketAppointmentRuleIDsGet()

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.

TicketAppointmentRuleGet()

get ticket appointment rule.

    my $Rule = $CalendarObject->TicketAppointmentRuleGet(
        CalendarID => 1,
        RuleID     => '9bb20ea035e7a9930652a9d82d00c725',
    );

returns rule hash:

TicketAppointmentTypesGet()

get defined ticket appointment types from config.

    my %TicketAppointmentTypes = $CalendarObject->TicketAppointmentTypesGet();

returns hash of appointment types:

    %TicketAppointmentTypes = ();

TicketAppointmentDelete()

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.

GetAccessToken()

get access token for the calendar.

    my $Token = $CalendarObject->GetAccessToken(
        CalendarID => 1,              # (required) CalendarID
        UserLogin  => 'agent-1',      # (required) User login
    );

Returns:

    $Token = 'rw';

GetTextColor()

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';
Scroll to Top