Util#

NAME#

Kernel::System::Util

DESCRIPTION#

All Util 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 $UtilObject = $Kernel::OM->Get('Kernel::System::Util');

IsITSMInstalled()#

Checks if ITSM is installed.

my $IsITSMInstalled = $UtilObject->IsITSMInstalled();

Returns 1 if ITSM is installed and 0 otherwise.

IsITSMIncidentProblemManagementInstalled()#

Checks if ITSMIncidentProblemManagement is installed.

my $IsITSMIncidentProblemManagementInstalled = $UtilObject->IsITSMIncidentProblemManagementInstalled();

Returns 1 if ITSMIncidentProblemManagement is installed and 0 otherwise.

IsFrontendContext()#

Checks if current code is being executed in frontend context, e.g. agent frontend.

my $IsFrontendContext = $UtilObject->IsFrontendContext();

Returns 1 if current code is being executed in frontend context.
Returns 0 if otherwise (e.g. console command context).

Base64DeepEncode()#

Base-64 encodes elements of given data for given keys.
If data is an array, all of its child elements will be checked for given keys whose elements
will be encoded recursively.

my $Base64EncodedData = $UtilObject->Base64DeepEncode(
    # Data can be a scalar, hash or array
    Data => {
        Article => {
            # ...
        },
        # ...
    },
    HashKeys => [
        # All 'Body' elements of array $Hash->{Articles} will be base-64 encoded.
        # Also can mean: $Hash->{Articles}->{Body}, if 'Articles' is a hash.
        # Will encode nothing if last key ('Body') cannot be reached or is not a scalar/string.
        'Articles->Body',

        'QueueData->Comment',
        # ...
    ],
);

DataStructureRemoveElements()#

Removes elements of given data for given keys.
If data is an array, all of its child elements will be checked for given keys whose elements
will be removed recursively.

my $Data = $UtilObject->DataStructureRemoveElements(
    # Data can be a scalar, hash or array
    Data => {
        Article => {
            # ...
        },
        # ...
    },
    HashKeys => [
        # All 'Body' elements of array $Hash->{Articles} will be removed.
        # Also can mean: $Hash->{Articles}->{Body}, if 'Articles' is a hash.
        # Will remove nothing if last key ('Body') cannot be reached or is not a scalar/string.
        'Articles->Body',

        'QueueData->Comment',
        # ...
    ],
);

GetInstalledDBCRUDObjects()#

Returns installed DBCRUD objects.

my $DBCRUDObjects = $UtilObject->GetInstalledDBCRUDObjects();

Returns:
my $DBCRUDObjects = [
    # DBCRUD objects as returned by $Kernel::OM->Get('Kernel::System::...')
];

XSSSanitizeValue()#

Takes a value which may be a reference to an array or hash, or a string that may be JSON, and tries to remove any contents suspicious of Cross Site Scripting.

If the string looks like plain text, a bunch of regexen (see _SanitizeScalar) is applied to it; otherwise if the string starts with “[” or “{”, we try to JSON-decode it and apply the sanitization recursively before reencoding it.

my $Value = $UtilObject->XSSSanitizeValue( $SuspiciousValue );

CreateUUIDString()#

Returns a new UUID in text form, or undef if there was an error. Any arguments are passed through to Data::UUID::create_str(). Unlike Data::UUID, hex digits are lowercased to conform to RFC4122.