LinkObject#

NAME#

Kernel::System::LinkObject - to link objects like tickets, faq entries, …

DESCRIPTION#

All functions to link objects like tickets, faq entries, …

PUBLIC INTERFACE#

new()#

Don’t use the constructor directly, use the ObjectManager instead:

my $LinkObject = $Kernel::OM->Get('Kernel::System::LinkObject');

PossibleTypesList()#

return a hash of all possible types

my %PossibleTypesList = $LinkObject->PossibleTypesList(
    Object1 => 'Ticket',
    Object2 => 'FAQ',
);

Return:

%PossibleTypesList = (
    'Normal'      => 1,
    'ParentChild' => 1,
);

PossibleObjectsList()#

return a hash of all possible objects

my %PossibleObjectsList = $LinkObject->PossibleObjectsList(
    Object => 'Ticket',
);

Return:

%PossibleObjectsList = (
    'Ticket' => 1,
    'FAQ'    => 1,
);

LinkAdd()#

add a new link between two elements

$True = $LinkObject->LinkAdd(
    SourceObject => 'Ticket',
    SourceKey    => '321',
    TargetObject => 'FAQ',
    TargetKey    => '5',
    Type         => 'ParentChild',
    State        => 'Valid',
    UserID       => 1,
);

LinkCleanup()#

deletes old links from database

return true

$True = $LinkObject->LinkCleanup(
    State => 'Temporary',
    Age   => ( 60 * 60 * 24 ),
);

LinkDelete()#

deletes a link

return true

$True = $LinkObject->LinkDelete(
    Object1 => 'Ticket',
    Key1    => '321',
    Object2 => 'FAQ',
    Key2    => '5',
    Type    => 'Normal',
    UserID  => 1,
);

LinkDeleteAll()#

delete all links of an object

$True = $LinkObject->LinkDeleteAll(
    Object => 'Ticket',
    Key    => '321',
    UserID => 1,
);

LinkListWithData()#

get all existing links for a given object with data of the other objects

my $LinkList = $LinkObject->LinkListWithData(
    Object           => 'Ticket',
    Key              => '321',
    Object2          => 'FAQ',         # (optional)
    State            => 'Valid',
    Type             => 'ParentChild', # (optional)
    Direction        => 'Target',      # (optional) default Both (Source|Target|Both)
    UserID           => 1,
    ObjectParameters => {              # (optional) backend specific flags
        Ticket => {
            IgnoreLinkedTicketStateTypes => 0|1,
        },
    },
);

Return:

$LinkList = {
    Ticket => {
        Normal => {
            Source => {
                12  => $DataOfItem12,
                212 => $DataOfItem212,
                332 => $DataOfItem332,
            },
        },
        ParentChild => {
            Source => {
                5 => $DataOfItem5,
                9 => $DataOfItem9,
            },
            Target => {
                4  => $DataOfItem4,
                8  => $DataOfItem8,
                15 => $DataOfItem15,
            },
        },
    },
    FAQ => {
        ParentChild => {
            Source => {
                5 => $DataOfItem5,
            },
        },
    },
};

LinkKeyList()#

return a hash with all existing links of a given object

my %LinkKeyList = $LinkObject->LinkKeyList(
    Object1   => 'Ticket',
    Key1      => '321',
    Object2   => 'FAQ',
    State     => 'Valid',
    Type      => 'ParentChild', # (optional)
    Direction => 'Target',      # (optional) default Both (Source|Target|Both)
    UserID    => 1,
);

Return

%LinkKeyList = (
    5   => 1,
    9   => 1,
    12  => 1,
    212 => 1,
    332 => 1,
);

LinkKeyListWithData()#

return a hash with all existing links of a given object

my %LinkKeyList = $LinkObject->LinkKeyListWithData(
    Object1   => 'Ticket',
    Key1      => '321',
    Object2   => 'FAQ',
    State     => 'Valid',
    Type      => 'ParentChild', # (optional)
    Direction => 'Target',      # (optional) default Both (Source|Target|Both)
    UserID    => 1,
);

Return:

%LinkKeyList = (
    5   => $DataOfItem5,
    9   => $DataOfItem9,
    12  => $DataOfItem12,
    212 => $DataOfItem212,
    332 => $DataOfItem332,
);

ObjectLookup()#

lookup a link object

$ObjectID = $LinkObject->ObjectLookup(
    Name => 'Ticket',
);

or

$Name = $LinkObject->ObjectLookup(
    ObjectID => 12,
);

TypeLookup()#

lookup a link type

$TypeID = $LinkObject->TypeLookup(
    Name   => 'Normal',
    UserID => 1,
);

or

$Name = $LinkObject->TypeLookup(
    TypeID => 56,
    UserID => 1,
);

TypeGet()#

get a link type

%TypeData = $LinkObject->TypeGet(
    TypeID => 444,
);

Return:

$TypeData{TypeID}
$TypeData{Name}
$TypeData{SourceName}
$TypeData{TargetName}
$TypeData{Pointed}
$TypeData{CreateTime}
$TypeData{CreateBy}
$TypeData{ChangeTime}
$TypeData{ChangeBy}

TypeList()#

return a 2 dimensional hash list of all valid link types

my %TypeList = $LinkObject->TypeList();

Return:

$TypeList{
    Normal => {
        SourceName => 'Normal',
        TargetName => 'Normal',
    },
    ParentChild => {
        SourceName => 'Parent',
        TargetName => 'Child',
    },
}

TypeGroupList()#

return a 2 dimensional hash list of all type groups

my %TypeGroupList = $LinkObject->TypeGroupList();

Return:

%TypeGroupList = (
    001 => [
        'Normal',
        'ParentChild',
    ],
    002 => [
        'Normal',
        'DependsOn',
    ],
    003 => [
        'ParentChild',
        'RelevantTo',
    ],
);

PossibleType()#

return true if both types are NOT together in a type group

my $True = $LinkObject->PossibleType(
    Type1 => 'Normal',
    Type2 => 'ParentChild',
);

StateLookup()#

lookup a link state

$StateID = $LinkObject->StateLookup(
    Name => 'Valid',
);

or

$Name = $LinkObject->StateLookup(
    StateID => 56,
);

StateList()#

return a hash list of all valid link states

my %StateList = $LinkObject->StateList(
    Valid => 0,   # (optional) default 1 (0|1)
);

Return:

$StateList{
    4 => 'Valid',
    8 => 'Temporary',
}

ObjectPermission()#

checks read permission for a given object and UserID.

$Permission = $LinkObject->ObjectPermission(
    Object => 'Ticket',
    Key    => 123,
    UserID => 1,
);

ObjectDescriptionGet()#

return a hash of object descriptions

%Description = $LinkObject->ObjectDescriptionGet(
    Object => 'Ticket',
    Key    => 123,
    UserID => 1,
);

Return:

%Description = (
    Normal => '',
    Long   => '',
);

ObjectSearch()#

return a hash reference of the search results.

$ObjectList = $LinkObject->ObjectSearch(
    Object       => 'ITSMConfigItem',
    SubObject    => 'Computer',        # (optional)
    SearchParams => $HashRef,          # (optional)
    UserID       => 1,
);

Returns:

$ObjectList = {
    Ticket => {
        NOTLINKED => {
            Source => {
                12  => $DataOfItem12,
                212 => $DataOfItem212,
                332 => $DataOfItem332,
            },
        },
    },
};