Kernel::System::SysConfig

NAME

Kernel::System::SysConfig – Functions to manage system configuration settings

DESCRIPTION

All functions to manage system configuration settings.

METHODS

new()

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

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

SettingGet()

Get SysConfig setting attributes.

    my %Setting = $SysConfigObject->SettingGet(
        Name            => 'Setting::Name',  # (required) Setting name
        Default         => 1,                # (optional) Returns the default setting attributes only
        ModifiedID      => '123',            # (optional) Get setting value for given ModifiedID.
        Deployed        => 1,                # (optional) Get deployed setting value. Default 0.
        OverriddenInXML => 1,                # (optional) Consider changes made in perl files. Default 0.
        Translate       => 1,                # (optional) Translate translatable strings in EffectiveValue. Default 0.
        NoLog           => 1,                # (optional) Do not log error if a setting does not exist.
        NoCache         => 1,                # (optional) Do not create cache.
        UserID          => 1,                # Required only if OverriddenInXML is set.
    );

Returns:

    %Setting = (
        DefaultID                => 123,
        ModifiedID               => 456,         # optional
        Name                     => "ProductName",
        Description              => "Defines the name of the application ...",
        Navigation               => "ASimple::Path::Structure",
        IsInvisible              => 1,           # 1 or 0
        IsReadonly               => 0,           # 1 or 0
        IsRequired               => 1,           # 1 or 0
        IsModified               => 1,           # 1 or 0
        IsValid                  => 1,           # 1 or 0
        HasConfigLevel           => 200,
        XMLContentRaw            => "The XML structure as it is on the config file",
        XMLContentParsed         => "XML parsed to Perl",
        XMLFilename              => "Framework.xml",
        EffectiveValue           => "Product 6",
        IsDirty                  => 1,           # 1 or 0
        ExclusiveLockGUID        => 'A32CHARACTERLONGSTRINGFORLOCKING',
        ExclusiveLockUserID      => 1,
        ExclusiveLockExpiryTime  => '2016-05-29 11:09:04',
        CreateTime               => "2016-05-29 11:04:04",
        CreateBy                 => 1,
        ChangeTime               => "2016-05-29 11:04:04",
        ChangeBy                 => 1,
        DefaultValue             => 'Old default value',
        OverriddenFileName        => '/opt/otrs/Kernel/Config/Files/ZZZ.pm',
    );

SettingUpdate()

Update an existing SysConfig Setting.

    my %Result = $SysConfigObject->SettingUpdate(
        Name                   => 'Setting::Name',           # (required) setting name
        IsValid                => 1,                         # (optional) 1 or 0, modified 0
        EffectiveValue         => $SettingEffectiveValue,    # (optional)
        ExclusiveLockGUID      => $LockingString,            # the GUID used to locking the setting
        UserID                 => 1,                         # (required) UserID
        NoValidation           => 1,                         # (optional) no value type validation.
    );

Returns:

    %Result = (
        Success => 1,        # or false in case of an error
        Error   => undef,    # error message
    );

SettingLock()

Lock setting(s) to the particular user.

    my $ExclusiveLockGUID = $SysConfigObject->SettingLock(
        DefaultID => 1,                     # the ID of the setting that needs to be locked
                                            #    or
        Name      => 'SettingName',         # the Name of the setting that needs to be locked
                                            #    or
        LockAll   => 1,                     # system locks all settings
        Force     => 1,                     # (optional) Force locking (do not check if it's already locked by another user). Default: 0.
        UserID    => 1,                     # (required)
    );

Returns:

    $ExclusiveLockGUID = 'azzHab72wIlAXDrxHexsI5aENsESxAO7';     # Setting locked

    or

    $ExclusiveLockGUID = undef;     # Not locked

SettingUnlock()

Unlock particular or all Setting(s).

    my $Success = $SysConfigObject->SettingUnlock(
        DefaultID => 1,                     # the ID of the setting that needs to be unlocked
                                            #   or
        Name      => 'SettingName',         # the name of the setting that needs to be locked
                                            #   or
        UnlockAll => 1,                     # unlock all settings
    );

Returns:

    $Success = 1;

SettingLockCheck()

Check setting lock status.

    my %Result = $SysConfigObject->SettingLockCheck(
        DefaultID           => 1,                     # the ID of the setting that needs to be checked
        ExclusiveLockGUID   => 1,                     # lock GUID
        ExclusiveLockUserID => 1,                     # UserID
    );

Returns:

    %Result = (
        Locked => 1,                        # lock status;
                                            # 0 - unlocked
                                            # 1 - locked to another user
                                            # 2 - locked to provided user
        User   => {                         # User data, provided only if Locked = 1
            UserLogin => ...,
            UserFirstname => ...,
            UserLastname => ...,
            ...
        },
    );

SettingEffectiveValueGet()

Calculate effective value for a given parsed XML structure.

    my $Result = $SysConfigObject->SettingEffectiveValueGet(
        Translate => 1,                      # (optional) Translate translatable strings. Default 0.
        Value  => [                          # (required) parsed XML structure
            {
                'Item' => [
                    {
                        'ValueType' => 'String',
                        'Content' => '3600',
                        'ValueRegex' => ''
                    },
                ],
            },
            Objects => {
                Select => { ... },
                PerlModule => { ... },
                # ...
            }
        ];
    );

Returns:

    $Result = '3600';

SettingRender()

Wrapper for Kernel::Output::HTML::SysConfig::SettingRender() – Returns the specific HTML for the setting.

    my $HTMLStr = $SysConfigObject->SettingRender(
        Setting   => {
            Name             => 'Setting Name',
            XMLContentParsed => $XMLParsedToPerl,
            EffectiveValue   => "Product 6",        # or a complex structure
            DefaultValue     => "Product 5",        # or a complex structure
            IsAjax           => 1,                  # (optional) is AJAX request. Default 0.
            # ...
        },
        RW => 1,                                    # (optional) Allow editing. Default 0.
    );

Returns:

    $HTMLStr = '<div class="Setting"><div class "Field"...</div></div>'        # or false in case of an error

SettingAddItem()

Wrapper for Kernel::Output::HTML::SysConfig::SettingAddItem() – Returns response that is sent when user adds new array/hash item.

    my %Result = $SysConfigObject->SettingAddItem(
        SettingStructure  => [],         # (required) array that contains structure
                                         #  where a new item should be inserted (can be empty)
        Setting           => {           # (required) Setting hash (from SettingGet())
            'DefaultID' => '8905',
            'DefaultValue' => [ 'Item 1', 'Item 2' ],
            'Description' => 'Simple array item(Min 1, Max 3).',
            'Name' => 'TestArray',
            ...
        },
        Key               => 'HashKey',  # (optional) hash key
        IDSuffix          => '_Array3,   # (optional) suffix that will be added to all input/select fields
                                         #    (it is used in the JS on Update, during EffectiveValue calculation)
        Value             => [           # (optional) Perl structure
            {
                'Array' => [
                    'Item' => [
                        {
                        'Content' => 'Item 1',
                        },
                        ...
                    ],
                ],
            },
        ],
        AddSettingContent => 0,          # (optional) if enabled, result will be inside of div with class "SettingContent"
    );

Returns:

    %Result = (
        'Item' => '<div class=\'SettingContent\'>
<input type=\'text\' id=\'TestArray_Array4\'
        value=\'Default value\' name=\'TestArray\' class=\' Entry\'/></div>',
    );

    or

    %Result = (
        'Error' => 'Error description',
    );

SettingsUpdatedList()

Checks which settings has been updated from provided Setting list and returns updated values.

    my @List = $SysConfigObject->SettingsUpdatedList(
        Settings => [                                               # (required) List of settings that needs to be checked
            {
                SettingName           => 'SettingName',
                ChangeTime            => '2017-01-13 11:23:07',
                IsLockedByAnotherUser => 0,
            },
            ...
        ],
        UserID => 1,                                                # (required) Current user id
    );

Returns:

    @List = [
        {
            ChangeTime            => '2017-01-07 11:29:38',
            IsLockedByAnotherUser => 1,
            IsModified            => 1,
            SettingName           => 'SettingName',
        },
        ...
    ];

SettingEffectiveValueCheck()

Check if provided EffectiveValue matches structure defined in DefaultSetting. Also returns EffectiveValue that might be changed.

    my %Result = $SysConfigObject->SettingEffectiveValueCheck(
        EffectiveValue => 'open',     # (optional)
        XMLContentParsed => {         # (required)
            Value => [
                {
                    'Item' => [
                        {
                            'Content' => "Scalar value",
                        },
                    ],
                },
            ],
        },
        StoreCache            => 1,               # (optional) Store result in the Cache. Default 0.
        SettingUID            => 'Default1234'    # (required if StoreCache)
        NoValidation          => 1,               # (optional) no value type validation.
        CurrentSystemTime     => 1507894796935,   # (optional) Use provided 1507894796935, otherwise calculate
        ExpireTime            => 1507894896935,   # (optional) Use provided ExpireTime for cache, otherwise calculate
        UserID                => 1,               # (required) UserID
    );

Returns:

    %Result = (
        EffectiveValue => 'closed',    # Note that resulting effective value can be different
        Success        => 1,
        Error          => undef,
    );

SettingReset()

Reset the modified value to the default value.

    my $Result = $SysConfigObject->SettingReset(
        Name                  => 'Setting Name',                # (required) Setting name
        ExclusiveLockGUID     => $LockingString,                # (optional) the GUID used to locking the setting
        UserID                => 1,                             # (required) UserID that creates modification
    );

Returns:

    $Result = 1;        # or false in case of an error

SettingDelete()

Removes a setting and all its values from the database.

If the setting still exists in the XML files it will be recreated with its default value in the next configuration rebuild

    my $Success = $SysConfigObject->SettingDelete(
        Name   => 'Setting Name',                # (required) Setting name
        UserID => 1,                             # (required)
    );

Returns:

    $Success = 1;        # or false in case of an error

ConfigurationTranslatedGet()

Returns a hash with all settings and translated metadata.

    my %Result = $SysConfigObject->ConfigurationTranslatedGet();

Returns:

    %Result = (
       'ACL::CacheTTL' => {
            'Category' => 'OTRS',
            'IsInvisible' => '0',
            'Metadata' => "ACL::CacheTTL--- '3600'
Cache-Zeit in Sekunden f\x{fc}r Datenbank ACL-Backends.",
        ...
    );

SettingNavigationToPath()

Returns path structure for given navigation group.

    my @Path = $SysConfigObject->SettingNavigationToPath(
        Navigation => 'Frontend::Agent::ToolBarModule',  # (optional)
    );

Returns:

    @Path = (
        {
            'Value' => 'Frontend',
            'Name' => 'Frontend',
        },
        {
            'Value' => 'Frontend::Agent',
            'Name' => 'Agent',
        },
        ...
    );

ConfigurationTranslatableStrings()

Returns a unique list of all translatable strings from the default settings.

    my @TranslatableStrings = $SysConfigObject->ConfigurationTranslatableStrings();

ConfigurationEntitiesGet()

Get all entities that are referred in any enabled Setting in complete SysConfig.

    my %Result = $SysConfigObject->ConfigurationEntitiesGet();

Returns:

    %Result = (
        'Priority' => {
            '3 normal' => [
                'Ticket::Frontend::AgentTicketNote###PriorityDefault',
                'Ticket::Frontend::AgentTicketPhone###Priority',
                ...
            ],
        },
        'Queue' => {
            'Postmaster' => [
                'Ticket::Frontend::CustomerTicketMessage###QueueDefault',
            ],
            'Raw' => [
                'PostmasterDefaultQueue',
            ],
        },
        ...
    );

ConfigurationEntityCheck()

Check if there are any enabled settings that refers to the provided Entity.

    my @Result = $SysConfigObject->ConfigurationEntityCheck(
        EntityType  => 'Priority',
        EntityName  => '3 normal',
    );

Returns:

    @Result = (
        'Ticket::Frontend::AgentTicketNote###PriorityDefault',
        'Ticket::Frontend::AgentTicketPhone###Priority',
        'Ticket::Frontend::AgentTicketBulk###PriorityDefault',
        ...
    );

ConfigurationXML2DB()

Load Settings defined in XML files to the database.

    my $Success = $SysConfigObject->ConfigurationXML2DB(
        UserID       => 1,               # UserID
        Directory    => '/some/folder',     # (optional) Provide directory where XML files are stored (default: Kernel/Config/Files/XML).
        Files        => [ 'config-1.xml', 'config-2.xml' ]     # (optional) Provide array reference of XML file names relative to Directory
        Force        => 1,               # (optional) Force Setting update, even if it's locked by another user. Default: 0.
        CleanUp      => 1,               # (optional) Remove all settings that are not present in XML files. Default: 0.
        NoValidation => 1,               # (optional) Skip validation of settings. Default: 0.
    );

Returns:

    $Success = 1;       # or false in case of an error.

ConfigurationNavigationTree()

Returns navigation tree in the hash format.

    my %Result = $SysConfigObject->ConfigurationNavigationTree(
        RootNavigation         => 'Parent',     # (optional) If provided only sub groups of the root navigation are returned.
        IsValid                => 1,            # (optional) By default, display all settings.
        Category               => 'OTRS'    # (optional)
    );

Returns:

    %Result = (
        'Core' => {
            'Core::Cache' => {},
            'Core::CustomerCompany' => {},
            'Core::CustomerUser' => {},
            'Core::Daemon' => {
                'Core::Daemon::ModuleRegistration' => {},
            },
            ...
        'Crypt' =>{
            ...
        },
        ...
    );

ConfigurationListGet()

Returns list of settings that matches provided parameters.

    my @List = $SysConfigObject->ConfigurationListGet(
        Navigation           => 'SomeNavigationGroup',  # (optional) limit to the settings that have provided navigation
        IsValid              => 1,                      # (optional) by default returns valid and invalid settings.
        Invisible            => 0,                      # (optional) Include Invisible settings. By default, not included.
        Translate            => 0,                      # (optional) Translate translatable string in EffectiveValue. Default 0.
        OverriddenInXML      => 1,                      # (optional) Consider changes made in Perl files. Default 0. Use it in modules only!
        UserID               => 1,                      # Required if OverriddenInXML is set.
    );

Returns:

    @List = (
        {
            DefaultID                => 123,
            ModifiedID               => 456,     # if modified
            Name                     => "ProductName",
            Description              => "Defines the name of the application ...",
            Navigation               => "ASimple::Path::Structure",
            IsInvisible              => 1,
            IsReadonly               => 0,
            IsRequired               => 1,
            IsValid                  => 1,
            HasConfigLevel           => 200,
            XMLContentRaw            => "The XML structure as it is on the config file",
            XMLContentParsed         => "XML parsed to Perl",
            XMLFilename              => "Daemon.xml",
            EffectiveValue           => "Product 6",
            DefaultValue             => "Product 5",
            IsModified               => 1,       # 1 or 0
            IsDirty                  => 1,       # 1 or 0
            ExclusiveLockGUID        => 'A32CHARACTERLONGSTRINGFORLOCKING',
            ExclusiveLockUserID      => 1,
            ExclusiveLockExpiryTime  => '2016-05-29 11:09:04',
            CreateTime               => "2016-05-29 11:04:04",
            ChangeTime               => "2016-05-29 11:04:04",
            OverriddenFileName        => 'ZZZDefauls.pm'
        },
        {
            DefaultID     => 321,
            Name          => 'FieldName',
            # ...
            CreateTime    => '2010-09-11 10:08:00',
            ChangeTime    => '2011-01-01 01:01:01',
        },
        # ...
    );

ConfigurationList()

Wrapper of Kernel::System::SysConfig::DB::DefaultSettingList() – Get list of all settings.

    my @SettingList = $SysConfigObject->ConfigurationList();

Returns:

    @SettingList = (
        {
            DefaultID => '123',
            Name      => 'SettingName1',
            IsDirty   => 1,
        },
        {
            DefaultID => '124',
            Name      => 'SettingName2',
            IsDirty   => 0
        },
        ...
    );

ConfigurationInvalidList()

Returns list of enabled settings that have invalid effective value.

    my @List = $SysConfigObject->ConfigurationInvalidList(
        CachedOnly  => 0,   # (optional) Default 0. If enabled, system will return cached value.
                            #                 If there is no cache yet, system will return empty list, but
                            #                 it will also trigger async call to generate cache.
        Undeployed  => 1,   # (optional) Default 0. Check settings that are not deployed as well.
        NoCache     => 1,   # (optional) Default 0. If enabled, system won't check the cached value.
    );

Returns:

    @List = ( "Setting1", "Setting5", ... );

ConfigurationDeploy()

Write configuration items from database into a perl module file.

    my %Result = $SysConfigObject->ConfigurationDeploy(
        Comments            => "Some comments",     # (optional)
        NoValidation        => 0,                   # (optional) 1 or 0, default 0, skips settings validation
        UserID              => 123,                 # if ExclusiveLockGUID is used, UserID must match the user that creates the lock
        Force               => 1,                   # (optional) proceed even if lock is set to another user
        NotDirty            => 1,                   # (optional) do not use any values from modified dirty settings
        AllSettings         => 1,                   # (optional) use dirty modified settings from all users
        DirtySettings       => [                    # (optional) use only this dirty modified settings from the current user
            'SettingOne',
            'SettingTwo',
        ],
    );

Returns:

    %Result = (
        Success => 1,           # Deployment successful.
    );

    or

    %Result = (
        Success => 0,           # Deployment failed.
        Error   => 'Error...',  # Error message (if available)
    );

ConfigurationDeployList()

Get deployment list with complete data.

    my @List = $SysConfigObject->ConfigurationDeployList();

Returns:

    @List = (
        {
            DeploymentID       => 123,
            Comments           => 'Some Comments',
            EffectiveValueStrg => $SettingEffectiveValues,      # String with the value of all settings,
                                                                #   as seen in the Perl configuration file.
            CreateTime         => "2016-05-29 11:04:04",
            CreateBy           => 123,
        },
        {
            DeploymentID       => 456,
            Comments           => 'Some Comments',
            EffectiveValueStrg => $SettingEffectiveValues2,     # String with the value of all settings,
                                                                #   as seen in the Perl configuration file.
            CreateTime         => "2016-05-29 12:00:01",
            CreateBy           => 123,
        },
        # ...
    );

ConfigurationDeploySync()

Updates ZZZAAuto.pm to the latest deployment found in the database.

    my $Success = $SysConfigObject->ConfigurationDeploySync();

ConfigurationDeployCleanup()

Cleanup old deployments from the database.

    my $Success = $SysConfigObject->ConfigurationDeployCleanup();

Returns:

    $Success = 1;       # or false in case of an error

ConfigurationDeployRead()

Reads deployment information from the written File.

    my %Deployment = $SysConfigObject->ConfigurationDeployRead();

Returns:

    %Deployment = (
        Success            => 1,
        DeploymentUUID     => '14906327941360ed8455f125d0450277',
        EffectiveValueStrg => $ProcesEffectiveValues,             # string with the value of all settings,
                                                                  #   as seen in the Perl configuration file.
        Inode              => 8041482,
        ModifiedTime       => 1685422853,
        StatusTime         => 1685422853,
    );

ConfigurationDeployGet()

Wrapper of Kernel::System::SysConfig::DB::DeploymentGet() – Get deployment information.

    my %Deployment = $SysConfigObject->ConfigurationDeployGet(
        DeploymentID   => 123,
        DeploymentUUID => '14906327941360ed8455f125d0450277',
    );

Returns:

    %Deployment = (
        DeploymentID       => 123,
        DeploymentUUID     => '14906327941360ed8455f125d0450277',
        Comments           => 'Some Comments',
        EffectiveValueStrg => $SettingEffectiveValues,      # String with the value of all settings,
                                                            #   as seen in the Perl configuration file.
        CreateTime         => '2016-05-29 11:04:04',
        CreateBy           => 123,
    );

ConfigurationDeployGetLast()

Wrapper of Kernel::System::SysConfig::DBDeploymentGetLast() – Get last deployment information.

    my %Deployment = $SysConfigObject->ConfigurationDeployGetLast();

Returns:

    %Deployment = (
        DeploymentID       => 123,
        Comments           => 'Some Comments',
        EffectiveValueStrg => $SettingEffectiveValues,      # String with the value of all settings,
                                                            #   as seen in the Perl configuration file.
        CreateTime         => "2016-05-29 11:04:04",
        CreateBy           => 123,
    );

ConfigurationDeploySettingsListGet()

Gets full modified settings information contained on a given deployment.

    my @List = $SysConfigObject->ConfigurationDeploySettingsListGet(
        DeploymentID => 123,
    );

Returns:

    @List = (
        {
            DefaultID                => 123,
            ModifiedID               => 456,
            ModifiedVersionID        => 789,
            Name                     => "ProductName",
            Description              => "Defines the name of the application ...",
            Navigation               => "ASimple::Path::Structure",
            IsInvisible              => 1,
            IsReadonly               => 0,
            IsRequired               => 1,
            IsValid                  => 1,
            HasConfigLevel           => 200,
            XMLContentRaw            => "The XML structure as it is on the config file",
            XMLContentParsed         => "XML parsed to Perl",
            EffectiveValue           => "Product 6",
            DefaultValue             => "Product 5",
            IsModified               => 1,       # 1 or 0
            IsDirty                  => 1,       # 1 or 0
            ExclusiveLockGUID        => 'A32CHARACTERLONGSTRINGFORLOCKING',
            ExclusiveLockUserID      => 1,
            ExclusiveLockExpiryTime  => '2016-05-29 11:09:04',
            CreateTime               => "2016-05-29 11:04:04",
            ChangeTime               => "2016-05-29 11:04:04",
        },
        {
            DefaultID         => 321,
            ModifiedID        => 654,
            ModifiedVersionID => 987,
             Name             => 'FieldName',
            # ...
            CreateTime => '2010-09-11 10:08:00',
            ChangeTime => '2011-01-01 01:01:01',
        },
        # ...
    );

ConfigurationIsDirtyCheck()

Check if there are not deployed changes on system configuration.

    my $Result = $SysConfigObject->ConfigurationIsDirtyCheck(
        UserID => 123,      # optional, the user that changes a modified setting
    );

Returns:

    $Result = 1;    # or 0 if configuration is not dirty.

ConfigurationDump()

Creates a YAML file with the system configuration settings.

    my $ConfigurationDumpYAML = $SysConfigObject->ConfigurationDump(
        OnlyValues           => 0,  # optional, default 0, dumps only the setting effective value instead of the whole setting attributes.
        SkipDefaultSettings  => 0,  # optional, default 0, do not include default settings
        SkipModifiedSettings => 0,  # optional, default 0, do not include modified settings
        DeploymentID         => 123, # optional, if it is provided the modified settings are retrieved from versions
    );

Returns:

    my $ConfigurationDumpYAML = '---
Default:
  Setting1:
    DefaultID: 23766
    Name: Setting1
    # ...
  Setting2:
  # ...
Modified:
  Setting1
    DefaultID: 23776
    ModifiedID: 1250
    Name: Setting1
    # ...
  # ...
JDoe:
  Setting2
    DefaultID: 23777
    ModifiedID: 1251
    Name: Setting2
    # ...
  # ...
# ...

or

    my $ConfigurationDumpYAML = $SysConfigObject->ConfigurationDump(
        OnlyValues => 1,
    );

Returns:

    my $ConfigurationDumpYAML = '---
Default:
  Setting1: Test
  Setting2: Test
  # ...
Modified:
  Setting1: TestUpdate
  # ...
JDoe:
  Setting2: TestUser
  # ...
# ...
';

ConfigurationLoad()

Takes a YAML file with settings definition and try to import it into the system.

    my $Success = $SysConfigObject->ConfigurationLoad(
        ConfigurationYAML   => $YAMLString,     # a YAML string in the format of L<ConfigurationDump()>
        UserID              => 123,
    );

ConfigurationDirtySettingsList()

Returns a list of setting names that are dirty.

    my @Result = $SysConfigObject->ConfigurationDirtySettingsList(
        ChangeBy => 123,
    );

Returns:

    $Result = ['SettingA', 'SettingB', 'SettingC'];

ConfigurationLockedSettingsList()

Returns a list of setting names that are locked in general or by user.

    my @Result = $SysConfigObject->ConfigurationLockedSettingsList(
        ExclusiveLockUserID       => 2, # Optional, ID of the user for which the default setting is locked
    );

Returns:

    $Result = ['SettingA', 'SettingB', 'SettingC'];

ConfigurationSearch()

Returns a list of setting names.

    my @Result = $SysConfigObject->ConfigurationSearch(
        Search           => 'The search string', # (optional)
        Category         => 'OTRS'           # (optional)
        IncludeInvisible => 1,                   # (optional) Default 0.
    );

Returns:

    $Result = ['SettingA', 'SettingB', 'SettingC'];

ConfigurationCategoriesGet()

Returns a list of categories with their filenames.

    my %Categories = $SysConfigObject->ConfigurationCategoriesGet();

Returns:

    %Categories = (
        All => {
            DisplayName => 'All Settings',
            Files => [],
        },
        OTRS => {
            DisplayName => 'OTRS',
            Files       => ['Calendar.xml', CloudServices.xml', 'Daemon.xml', 'FAQ.xml', 'Framework.xml', 'GenericInterface.xml', 'ProcessManagement.xml', 'Ticket.xml' ],
        },
        # ...
    );

ForbiddenValueTypesGet()

Returns a hash of forbidden value types.

    my %ForbiddenValueTypes = $SysConfigObject->ForbiddenValueTypesGet();

Returns:

    %ForbiddenValueType = (
        String => [],
        Select => ['Option'],
        ...
    );

ValueAttributeList()

Returns a hash of forbidden value types.

    my @ValueAttributeList = $SysConfigObject->ValueAttributeList();

Returns:

    @ValueAttributeList = (
        "Content",
        "SelectedID",
    );

SettingsSet()

This method locks provided settings(by force), updates them and deploys the changes (by force).

    my $Success = $SysConfigObject->SettingsSet(
        UserID   => 1,                                      # (required) UserID
        Comments => 'Deployment comment',                   # (optional) Comment
        Settings => [                                       # (required) List of settings to update.
            {
                Name                   => 'Setting::Name',  # (required)
                EffectiveValue         => 'Value',          # (optional)
                IsValid                => 1,                # (optional)
            },
            ...
        ],
    );

Returns:

    $Success = 1;

OverriddenFileNameGet()

Returns file name which overrides setting Effective value.

    my $FileName = $SysConfigObject->OverriddenFileNameGet(
        SettingName    => 'Setting::Name',  # (required)
        UserID         => 1,                # (required)
        EffectiveValue => '3',              # (optional) EffectiveValue stored in the DB.
    );

Returns:

    $FileName = 'ZZZUpdate.pm';

GlobalEffectiveValueGet()

Returns global effective value for provided setting name.

    my $EffectiveValue = $SysConfigObject->GlobalEffectiveValueGet(
        SettingName    => 'Setting::Name',  # (required)
    );

Returns:

    $EffectiveValue = 'test';

PRIVATE METHODS

_IsOverriddenInModule()

Helper method to check if setting is overridden in specific module.

    my $Overridden = $SysConfigObject->_IsOverriddenInModule(
        Module               => "Kernel::Config::Files::ZZZAAuto",
        SettingStructure     => [ 'DashboardBackend', '0000-ProductNotify' ],
        LoadedEffectiveValue => 'Value',
    );

_FileWriteAtomic()

Writes a file in an atomic operation. This is achieved by creating a temporary file, filling and renaming it. This avoids inconsistent states when the file is updated.

    my $Success = $SysConfigObject->_FileWriteAtomic(
        Filename => "$Self->{Home}/Kernel/Config/Files/ZZZAAuto.pm",
        Content  => \$NewContent,
    );

_ConfigurationTranslatableStrings()

Gathers strings marked as translatable from a setting XML parsed content and saves it on ConfigurationTranslatableStrings global variable.

    $SysConfigObject->_ConfigurationTranslatableStrings(
        Data => $Data,      # could be SCALAR, ARRAY or HASH
    );

_DBCleanUp();

Removes all settings defined in the database (including default and modified) that are not included in the settings parameter

    my $Success = $SysConfigObject->_DBCleanUp(
        Settings => {
            'ACL::CacheTTL' => {
                XMLContentParsed => '
                    <Setting Name="SettingName" Required="1" Valid="1">
                        <Description Translatable="1">Test.</Description>
                        # ...
                    </Setting>',
                XMLContentRaw => {
                    Description => [
                        {
                            Content      => 'Test.',
                            Translatable => '1',
                        },
                    ],
                    Name  => 'Test',
                    # ...
                },
            # ...
        };
        UserID => 123,
    );

Returns:

    $Success = 1;       # or false in case of a failure

Returns navigation as a tree (in a hash).

    my %Result = $SysConfigObject->_NavigationTree(
        'Array' => [                            # Array of setting navigation items
            'Core',
            'Core::CustomerUser',
            'Frontend',
        ],
        'Tree' => {                             # Result from previous recursive call
            'Core' => {
                'Core::CustomerUser' => {},
            },
        },
    );

Returns:

    %Result = (
        'Core' => {
            'Core::CustomerUser' => {},
        },
        'Frontend' => {},
    );

_ConfigurationEntitiesGet();

Returns hash of used entities for provided Setting value.

    my %Result = $SysConfigObject->_ConfigurationEntitiesGet(
        'Name'   => 'Ticket::Frontend::AgentTicketPriority###Entity',   # setting name
        'Result' => {},                                                 # result from previous recursive call
        'Value'  => [                                                   # setting Value
            {
                'Item' => [
                    {
                        'Content'         => '3 medium',
                        'ValueEntityType' => 'Priority',
                        'ValueRegex'      => '',
                        'ValueType'       => 'Entity',
                    },
                ],
            },
        ],
    );

Returns:

    %Result = {
        'Priority' => {
            '3 medium' => [
                'Ticket::Frontend::AgentTicketPriority###Entity',
            ],
        },
    };

_EffectiveValues2PerlFile()

Converts effective values from settings into a combined perl hash ready to write into a file.

    my $FileString = $SysConfigObject->_EffectiveValues2PerlFile(
        Settings  => [
            {
                Name           => 'SettingName',
                IsValid        => 1,
                EffectiveValue => $ValueStructure,
            },
            {
                Name           => 'AnotherSettingName',
                IsValid        => 0,
                EffectiveValue => $AnotherValueStructure,
            },
            # ...
        ],
        TargetPath => 'Kernel/Config/Files/ZZZAAuto.pm',
    );

_SettingEffectiveValueCheck()

Recursive helper for SettingEffectiveValueCheck().

    my %Result = $SysConfigObject->_SettingEffectiveValueCheck(
        EffectiveValue => 'open',                           # (optional) The EffectiveValue to be checked,
                                                            #   (could be also a complex structure).
        XMLContentParsed => {                               # (required) The XMLContentParsed value from Default Setting.
            Value => [
                {
                    'Item' => [
                        {
                            'Content' => "Scalar value",
                        },
                    ],
                },
            ],
        },
        NoValidation        => $Param{NoValidation},        # (optional), skip validation
        CurrentSystemTime   => 1507894796935,               # (optional) Use provided 1507894796935, otherwise calculate
        ExpireTime          => 1507894896935,               # (optional) Use provided ExpireTime for cache, otherwise calculate
        UserID              => 1,                           # (required) UserID
    );

Returns:

    %Result = (
        EffectiveValue => 'closed',    # Note that EffectiveValue can be changed.
        Success        => 1,           # or false in case of fail
        Error          => undef,       # or error string
    );

_SettingEffectiveValueCheckCacheSet() Sets cache for EffectiveValueCheck to the provided value.

    $SysConfigObject->_SettingEffectiveValueCheckCacheSet(
        Value => {                              (required)
            Default180920170714165331 => {
                Success => 1,
            },
            ...
        },
        NoValidation => 0,                      (optional)
    );

_GetSettingsToDeploy()

Returns the correct list of settings for a deployment taking the settings from different sources:

    NotDirty:      fetch default settings plus already deployed modified settings.
    AllSettings:   fetch default settings plus all modified settings already deployed or not.
    DirtySettings: fetch default settings plus already deployed settings plus all not deployed settings in the list.

    my @SettingList = $SysConfigObject->_GetSettingsToDeploy(
        NotDirty      => 1,                                         # optional - exclusive (1||0)
        All           => 1,                                         # optional - exclusive (1||0)
        DirtySettings => [ 'SettingName1', 'SettingName2' ],        # optional - exclusive
    );

    @SettingList = (
        {
            DefaultID                => 123,
            Name                     => "ProductName",
            Description              => "Defines the name of the application ...",
            Navigation               => "ASimple::Path::Structure",
            IsInvisible              => 1,
            IsReadonly               => 0,
            IsRequired               => 1,
            IsValid                  => 1,
            HasConfigLevel           => 200,
            XMLContentRaw            => "The XML structure as it is on the config file",
            XMLContentParsed         => "XML parsed to Perl",
            EffectiveValue           => "Product 6",
            DefaultValue             => "Product 5",
            IsModified               => 1,       # 1 or 0
            IsDirty                  => 1,       # 1 or 0
            ExclusiveLockGUID        => 'A32CHARACTERLONGSTRINGFORLOCKING',
            ExclusiveLockUserID      => 1,
            ExclusiveLockExpiryTime  => '2016-05-29 11:09:04',
            CreateTime               => "2016-05-29 11:04:04",
            ChangeTime               => "2016-05-29 11:04:04",
        },
        {
            DefaultID => 321,
            Name      => 'FieldName',
            # ...
            CreateTime => '2010-09-11 10:08:00',
            ChangeTime => '2011-01-01 01:01:01',
        },
        # ...
    );

_HandleSettingsToDeploy()

Creates modified versions of dirty settings to deploy and removed the dirty flag.

    NotDirty:      Removes dirty flag just for default settings
    AllSettings:   Create a version for all dirty settings and removed dirty flags for all default and modified settings
    DirtySettings: Create a version and remove dirty fag for the modified settings in the list, remove dirty flag for all default settings

    my $Success = $SysConfigObject->_HandleSettingsToDeploy(
        NotDirty            => 1,                                         # optional - exclusive (1||0)
        AllSettings         => 1,                                         # optional - exclusive (1||0)
        DirtySettings       => [ 'SettingName1', 'SettingName2' ],        # optional - exclusive
        DeploymentTimeStamp => 2017-12-12 12:00:00'
        UserID              => 123,
    );

Returns:

    $Success = 1;       # or false in case of a failure

_SettingTranslatedGet()

Helper method for ConfigurationTranslatedGet().

    my %Result = $SysConfigObject->_SettingTranslatedGet(
        Language => 'de',               # (required) User language
        Name     => 'SettingName',      # (required) Setting name
        Silent   => 1,                  # (optional) Default 1
    );

Returns:

    %Result = (
       'ACL::CacheTTL' => {
            'Category' => 'OTRS',
            'IsInvisible' => '0',
            'Metadata' => "ACL::CacheTTL--- '3600'
Cache-Zeit in Sekunden f\x{fc}r Datenbank ACL-Backends.",
    );

_ValueTypesList()

Returns a hash of forbidden value types.

    my @ValueTypes = $SysConfigObject->_ValueTypesList();

Returns:

    @ValueTypes = (
        "Checkbox",
        "Select",
        ...
    );

_DefaultSettingAddBulk()

Helper method for ConfigurationXML2DB() – bulk insert.

    my $Success = $SysConfigObject->_DefaultSettingAddBulk(
        Settings => {                   # (required) Hash of settings to insert
            'SettingName' => {

            },
            ...
        },
        SettingList => [                # (required) List of settings
            ...
        ],
        UserID => 1,                    # (required) UserID
    );

_UserConfigDirectory()

Returns the directory where the files of the user specific settings are located.

    my $Path = $SysConfigObject->_UserConfigDirectory();
Scroll to Top