
##
DB
##


****
NAME
****


Kernel::System::SysConfig::DB - Functions to manage system configuration settings interactions with the database.


****************
PUBLIC INTERFACE
****************


new()
=====


Create an object. Do not use it directly, instead use:


.. code-block:: perl

     use Kernel::System::ObjectManager;
     local $Kernel::OM = Kernel::System::ObjectManager->new();
     my $SysConfigDBObject = $Kernel::OM->Get('Kernel::System::SysConfig::DB');



DefaultSettingAdd()
===================


Add a new SysConfig default entry.


.. code-block:: perl

     my $DefaultID = $SysConfigDBObject->DefaultSettingAdd(
         Name                     => "ProductName",                 # (required)
         Description              => "Setting description",         # (required)
         Navigation               => "ASimple::Path::Structure",    # (required)
         IsInvisible              => 1,                             # (optional) 1 or 0, default 0
         IsReadonly               => 0,                             # (optional) 1 or 0, default 0
         IsRequired               => 1,                             # (optional) 1 or 0, default 0
         IsValid                  => 1,                             # (optional) 1 or 0, default 0
         HasConfigLevel           => 200,                           # (optional) default 0
         UserModificationPossible => 0,                             # (optional) 1 or 0, default 0
         UserModificationActive   => 0,                             # (optional) 1 or 0, default 0
         UserPreferencesGroup     => 'Some Group',                  # (optional)
         XMLContentRaw            => $XMLString,                    # (required) the setting XML structure as it is on the config file
         XMLContentParsed         => $XMLParsedToPerl,              # (required) the setting XML structure converted into a Perl structure
         XMLFilename              => 'Framework.xml',               # (required) the name of the XML file
         EffectiveValue           => $SettingEffectiveValue,        # (required) the value as will be stored in the Perl configuration file
         ExclusiveLockExpiryTime  => '2017-02-01 12:23:13',         # (optional) If not provided, method will calculate it.
         UserID                   => 123,
         NoCleanup                => 0,                             # (optional) Default 0. If enabled, system WILL NOT DELETE CACHE. In this case, it must be done manually.
                                                                    #    USE IT CAREFULLY.
     );


Returns:


.. code-block:: perl

     my $DefaultID = 123;  # false in case of an error



DefaultSettingBulkAdd()
=======================


Add new SysConfig default entries.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingBulkAdd(
         Settings => {                                                 # (required) Hash of settings
             "ACL::CacheTTL" => {
                 "EffectiveValue" => "--- '3600'\n",
                 "XMLContentParsed" => {
                     "Description" => [
                         {
                             "Content" => "Cache time in ...",
                             "Translatable" => 1
                         },
                     ],
                     "Name" => "ACL::CacheTTL",
                     "Navigation" => [
                         {
                             "Content" => "Core::Ticket::ACL"
                         },
                     ],
                     "Required" => 1,
                     "Valid" => 1,
                     "Value" => [
                         {
                             "Item" => [
                                 {
                                     "Content" => 3600,
                                     "ValueRegex" => "^\\d+\$",
                                     "ValueType" => "String"
                                 },
                             ],
                         },
                     ],
                 },
                 "XMLContentParsedYAML" => "---\nDescription:\n- Content: Cache...",
                 "XMLContentRaw" => "<Setting Name=\"ACL::CacheTTL\" Required=\"1\" ...",
                 "XMLFilename" => "Ticket.xml"
             },
             # ...
         },
         SettingList => [                                                # list of current settings in DB
             {
                 DefaultID         => '123',
                 Name              => 'SettingName1',
                 IsDirty           => 1,
                 ExclusiveLockGUID => 0,
             },
             # ...
         ],
         UserID => 1,                                                    # (required) UserID
     );



DefaultSettingVersionBulkAdd()
==============================



.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingVersionBulkAdd(
         Settings => {                                                 # (required) Hash of settings
             "ACL::CacheTTL" => {
                 "EffectiveValue" => "--- '3600'\n",
                 "XMLContentParsed" => {
                     "Description" => [
                         {
                             "Content" => "Cache time in ...",
                             "Translatable" => 1
                         },
                     ],
                     "Name" => "ACL::CacheTTL",
                     "Navigation" => [
                         {
                             "Content" => "Core::Ticket::ACL"
                         },
                     ],
                     "Required" => 1,
                     "Valid" => 1,
                     "Value" => [
                         {
                             "Item" => [
                                 {
                                     "Content" => 3600,
                                     "ValueRegex" => "^\\d+\$",
                                     "ValueType" => "String"
                                 },
                             ],
                         },
                     ],
                 },
                 "XMLContentParsedYAML" => "---\nDescription:\n- Content: Cache...",
                 "XMLContentRaw" => "<Setting Name=\"ACL::CacheTTL\" Required=\"1\" ...",
                 "XMLFilename" => "Ticket.xml"
             },
             # ...
         },
         SettingList => [                                                # list of current settings in DB
             {
                 DefaultID         => '123',
                 Name              => 'SettingName1',
                 IsDirty           => 1,
                 ExclusiveLockGUID => 0,
             },
             # ...
         ],
         UserID => 1,                                                    # (required) UserID
     );



DefaultSettingGet()
===================


Get SysConfig default entry.


.. code-block:: perl

     my %DefaultSetting = $SysConfigDBObject->DefaultSettingGet(
         Name        => "TheName", # (required) Setting name - prefered parameter.
                                   # or
         DefaultID   => 4,         # (required) DefaultID. Slightly slower execution.
         NoCache     => 0,         # (optional) Default 0. If 1, cache will not be created.
     );


Returns:


.. code-block:: perl

     %DefaultSetting = (
         DefaultID                => "123",
         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
         IsValid                  => 1,         # 1 or 0
         HasConfigLevel           => 200,
         UserModificationPossible => 0,         # 1 or 0
         UserModificationActive   => 0,         # 1 or 0
         UserPreferencesGroup     => 'Some Group',
         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,
         SettingUID               => 'Default12320160529110404',
     );



DefaultSettingLookup()
======================


Default setting lookup.


.. code-block:: perl

     my %Result = $SysConfigDBObject->DefaultSettingLookup(
         Name        => "TheName", # (required)
                                   # or
         DefaultID   => 4,         # (required)
     );


Returns:


.. code-block:: perl

     %Result = (
         DefaultID      => 4,
         Name           => 'TheName',
     );



DefaultSettingDelete()
======================


Delete a default setting from the database.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingDelete(
         DefaultID => 123,
     );
 
     my $Success = $SysConfigDBObject->DefaultSettingDelete(
         Name => 'Name',
     );


Returns:


.. code-block:: perl

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



DefaultSettingUpdate()
======================


Update SysConfig default entry.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingUpdate(
         DefaultID                => 123,
         Name                     => "ProductName",
         Description              => "Defines the name of the application ...",
         Navigation               => "ASimple::Path::Structure",
         IsInvisible              => 1,             # 1 or 0, optional, default 0
         IsReadonly               => 0,             # 1 or 0, optional, default 0
         IsRequired               => 1,             # 1 or 0, optional, default 0
         IsValid                  => 1,             # 1 or 0, optional, default 0
         HasConfigLevel           => 200,           # optional, default 0
         UserModificationPossible => 0,             # 1 or 0, optional, default 0
         UserModificationActive   => 0,             # 1 or 0, optional, default 0
         UserPreferencesGroup     => 'Some Group',
         UserPreferencesGroup     => 'Advanced',    # optional
         XMLContentRaw            => $XMLString,    # the XML structure as it is on the config file
         XMLContentParsed         => $XMLParsedToPerl,
         XMLFilename              => 'Framework.xml',
         ExclusiveLockGUID        => 1,
         EffectiveValue           => $SettingEffectiveValue,
         UserID                   => 1,
     );


Returns:


.. code-block:: perl

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



DefaultSettingSearch()
======================


Search for settings which contains given term(Search) in the xml_content_raw column.


.. code-block:: perl

     my @Result = $SysConfigDBObject->DefaultSettingSearch(
         Search          => 'Entity',                              # Search term
         SearchType      => 'XMLContent',                          # XMLContent or Metadata
         CategoryFiles   => ['Framework.xml', 'Ticket.xml', ],     # (optional)
         Valid           => 0,                                     # (optional) By default, system returns all Settings (valid and invalid)
                                                                   #   if set to 1, search only for valid,
                                                                   #   if set to 0, search also for invalid.
         IncludeInvisible => 0,                                    # (optional) Default 0
     );


or


.. code-block:: perl

     my @Result = $SysConfigDBObject->DefaultSettingSearch(
         Search         => ['Framework.xml' 'Ticket,xml'],
         SearchType     => 'Filename',
         Valid          => 1,
     );


Returns:


.. code-block:: perl

     @Result = (
         'ACL::CacheTTL',
         'ACLKeysLevel1Change',
         # ...
     );



DefaultSettingListGet()
=======================


Get default setting list with complete data.


.. code-block:: perl

     my @List = $SysConfigDBObject->DefaultSettingListGet(
         IsInvisible              => 1,                                  # 1 or 0
         IsReadonly               => 0,                                  # 1 or 0
         IsRequired               => 1,                                  # 1 or 0
         IsValid                  => 1,                                  # 1 or 0
         IsDirty                  => 1,                                  # 1 or 0
         HasConfigLevel           => 0,                                  # 1 or 0
         UserModificationPossible => 0,                                  # 1 or 0
         UserModificationActive   => 0,                                  # 1 or 0
         UserPreferencesGroup     => 'Some Group',
         Navigation               => 'ASimple::Path::Structure',
         Locked                   => 1, # check for locked settings
         Category                 => 'OTRS',                             # optional (requires CategoryFiles)
         CategoryFiles            => ['Framework.xml', 'Ticket.xml', ],  # optional (requires Category)
         NoCache                  => 0,                                  # (optional) Default 0. If set, system will not generate cache.
     );


Returns:


.. code-block:: perl

     @List = (
         {
             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,
             UserModificationPossible => 0,          # 1 or 0
             UserModificationActive   => 0,          # 1 or 0
             UserPreferencesGroup     => 'Advanced', # optional
             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,
             SettingUID               => 'Default4717141789',
         },
         {
             DefaultID => 321,
             Name      => 'FieldName',
             # ...
             ChangeTime => '2011-01-01 01:01:01',
             ChangeBy                 => 1,
             SettingUID               => 'Default4717141781',
         },
         # ...
     );



DefaultSettingList()
====================


Get list of all settings.


.. code-block:: perl

     my @DefaultSettings = $SysConfigDBObject->DefaultSettingList(
         IncludeInvisible => 0,   # (optional) Include invisible. Default 0.
         IsDirty          => 0,   # (optional) Filter settings by IsDirty. If not provided, returns all settings.
         Locked           => 0,   # (optional) Filter locked settings.
     );


Returns:


.. code-block:: perl

     @DefaultSettings = (
         {
             DefaultID         => '123',
             Name              => 'SettingName1',
             IsDirty           => 1,
             IsVisible         => 1,
             ExclusiveLockGUID => 0,
             XMLFilename       => 'Filename.xml',
         },
         {
             DefaultID         => '124',
             Name              => 'SettingName2',
             IsDirty           => 0,
             IsVisible         => 1,
             ExclusiveLockGUID => 'fjewifjowj...',
             XMLFilename       => 'Filename.xml',
         },
         # ...
     );



DefaultSettingLock()
====================


Lock Default setting(s) to the particular user.


.. code-block:: perl

     my $ExclusiveLockGUID = $SysConfigDBObject->DefaultSettingLock(
         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:


.. code-block:: perl

     $ExclusiveLockGUID = 'azzHab72wIlAXDrxHexsI5aENsESxAO7';     # Setting locked
 
     or
 
     $ExclusiveLockGUID = undef;     # Not locked



DefaultSettingIsLocked()
========================


Check if particular Default Setting is locked.


.. code-block:: perl

     my $Locked = $SysConfigDBObject->DefaultSettingIsLocked(
         DefaultID     => 1,                 # the ID of the setting that needs to be checked
                                         #   or
         Name          => 'SettingName',     # the Name of the setting that needs to be checked
         GetLockUserID => 1,                 # optional, it will return the ExclusiveLockUserID in case it exist
     );


Returns:


.. code-block:: perl

     $Locked = 1;    # Locked
     or
     $Locked = 123   # The UserID



DefaultSettingIsLockedByUser()
==============================


Check if particular Default Setting is locked.


.. code-block:: perl

     my $LockedByUser = $SysConfigDBObject->DefaultSettingIsLockedByUser(
         DefaultID             => 1,                 # the ID of the setting that needs to be checked
                                                     #   or
         Name                  => 'SettingName',     # the name of the setting that needs to be checked
         ExclusiveLockUserID   => 2,                 # the user should have locked the setting
         ExclusiveLockGUID     => 'AGUIDSTRING',     # the GUID used to locking the setting
     );


Returns:


.. code-block:: perl

     $LockedByUser = 1;



DefaultSettingUnlock()
======================


Unlock particular or all Default Setting(s).


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingUnlock(
         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:


.. code-block:: perl

     $Success = 1;



DefaultSettingDirtyCleanUp()
============================


Removes the IsDirty flag from default settings.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingDirtyCleanUp(
         AllSettings => 0,   # (default 0) Reset all dirty settings.
     );


Returns:


.. code-block:: perl

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



DefaultSettingVersionAdd()
==========================


Add a new SysConfig default version entry.


.. code-block:: perl

     my $DefaultVersionID = $SysConfigDBObject->DefaultSettingVersionAdd(
         DefaultID                => 456,
         Name                     => "ProductName",
         Description              => "Defines the name of the application ...",
         Navigation               => "ASimple::Path::Structure",
         IsInvisible              => 1,                             # 1 or 0, optional, default 0
         IsReadonly               => 0,                             # 1 or 0, optional, default 0
         IsRequired               => 1,                             # 1 or 0, optional, default 0
         IsValid                  => 1,                             # 1 or 0, optional, default 0
         HasConfigLevel           => 200,                           # optional, default 0
         UserModificationPossible => 0,                             # 1 or 0, optional, default 0
         UserModificationActive   => 0,                             # 1 or 0, optional, default 0
         UserPreferencesGroup     => 'Advanced',                    # optional
         XMLContentRaw            => $XMLString,                    # the XML structure as it is on the config file
         XMLContentParsed         => $XMLParsedToPerl,              # the setting XML structure converted into YAML
         XMLFilename              => 'Framework.xml',               # the name of the XML file
         EffectiveValue           => $YAMLEffectiveValue,           # YAML EffectiveValue
         UserID                   => 1,
         NoCleanup                => 0,                             # (optional) Default 0. If enabled, system WILL NOT DELETE CACHE. In this case, it must be done manually.
                                                                    #    USE IT CAREFULLY.
         NoVersionID              => 1,                             # 1 or 0, optional, default 0, prevents the return of DefaultVersionID and returns only 1 in case of success.
     );


Returns:


.. code-block:: perl

     my $DefaultVersionID = 123;  # false in case of an error



DefaultSettingVersionGet()
==========================


Get SysConfig default version entry.


.. code-block:: perl

     my %DefaultSettingVersion = $SysConfigDBObject->DefaultSettingVersionGet(
         DefaultVersionID => 123,
     );


Returns:


.. code-block:: perl

     %DefaultSettingVersion = (
         DefaultVersionID         => 123,
         DefaultID                => 456,
         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
         IsValid                  => 1,         # 1 or 0
         HasConfigLevel           => 200,
         UserModificationPossible => 0,         # 1 or 0
         UserModificationActive   => 0,         # 1 or 0
         UsePreferencesGroup      => 'Advanced',         # optional
         XMLContentRaw            => "The XML structure as it is on the config file",
         XMLContentParsed         => "XML parsed to Perl",
         XMLFilename              => 'Framework.xml',
         EffectiveValue           => "Product 6",
         CreateTime               => "2016-05-29 11:04:04",
         CreateBy                 => 44,
         ChangeTime               => "2016-05-29 11:04:04",
         ChangeBy                 => 88,
     );



DefaultSettingVersionDelete()
=============================


Delete a default setting version from list based on default version ID or default ID.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingVersionDelete(
         DefaultVersionID => 123,
     );


or


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingVersionDelete(
         DefaultID => 45,
     );


or


.. code-block:: perl

     my $Success = $SysConfigDBObject->DefaultSettingVersionDelete(
         Name => 'AnyName',
     );


Returns:


.. code-block:: perl

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



DefaultSettingVersionGetLast()
==============================


Get last deployment.


.. code-block:: perl

     my %DefaultSettingVersionGetLast = $SysConfigDBObject->DefaultSettingVersionGetLast(
         DefaultID => 456,
     );


Returns:


.. code-block:: perl

     %DefaultSettingVersion = (
         DefaultVersionID         => 123,
         DefaultID                => 456,
         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
         IsValid                  => 1,         # 1 or 0
         HasConfigLevel           => 200,
         UserModificationPossible => 0,         # 1 or 0
         UserModificationActive   => 0,         # 1 or 0
         UsePreferencesGroup      => 'Advanced',         # optional
         XMLContentRaw            => "The XML structure as it is on the config file",
         XMLContentParsed         => "XML parsed to Perl",
         XMLFilename              => 'Framework.xml',
         EffectiveValue           => "Product 6",
         CreateTime               => "2016-05-29 11:04:04",
         ChangeTime               => "2016-05-29 11:04:04",
     );



DefaultSettingVersionListGet()
==============================


Get version setting list with complete data.


.. code-block:: perl

     my @List = $SysConfigDBObject->DefaultSettingVersionListGet(
         Name       => 'SettingName',      # optional
                                           # or
         DefaultID  => 123,                # optional
     );


Returns:


.. code-block:: perl

     @List = (
         {
             DefaultVersionID         => 123,
             DefaultID                => 456,
             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
             IsValid                  => 1,          # 1 or 0
             HasConfigLevel           => 200,
             UserModificationPossible => 0,          # 1 or 0
             UserModificationActive   => 0,          # 1 or 0
             UserPreferencesGroup     => 'Advanced', # optional
             XMLContentRaw            => "The XML structure as it is on the config file",
             XMLContentParsed         => "XML parsed to Perl",
             XMLFilename              => 'Framework.xml',
             EffectiveValue           => "Product 6",
             CreateTime               => "2016-05-29 11:04:04",
             ChangeTime               => "2016-05-29 11:04:04",
         },
         {
             DefaultVersionID => 321,
             DefaultID        => 890,
             Name             => 'FieldName',
             # ...
             CreateTime => '2010-09-11 10:08:00',
             ChangeTime => '2011-01-01 01:01:01',
         },
         # ...
     );



ModifiedSettingAdd()
====================


Add a new SysConfig modified entry.


.. code-block:: perl

     my $ModifiedID = $SysConfigDBObject->ModifiedSettingAdd(
         DefaultID                   => 456,
         Name                        => "ProductName",
         IsValid                     => 1,                             # 1 or 0, optional (uses the value from DefaultSetting if not defined)
         UserModificationPossible    => 0,                             # 1 or 0, optional (uses the value from DefaultSetting if not defined)
         UserModificationActive      => 0,                             # 1 or 0, optional (uses the value from DefaultSetting if not defined)
         ResetToDefault              => 0,                             # 1 or 0, optional, modified 0
         EffectiveValue              => $SettingEffectiveValue,
         TargetUserID                => 2,                             # Optional, ID of the user for which the modified setting is meant,
                                                                       #   leave it undef for global changes.
         ExclusiveLockGUID           => $LockingString,                # the GUID used to lock the setting
         DeploymentExclusiveLockGUID => $LockingString,                # the GUID used to lock the deployment (in case of deployment failure)
         UserID                      => 1,
     );


Returns:


.. code-block:: perl

     my $ModifiedID = 123;  # false in case of an error



ModifiedSettingGet()
====================


Get SysConfig modified value.


.. code-block:: perl

     my %ModifiedSetting = $SysConfigDBObject->ModifiedSettingGet(
         ModifiedID            => 123,               # ModifiedID or NAME are required.
         Name                  => 'Setting::Name',
         TargetUserID          => 2,                 # The ID of the user for which the modified setting is meant,
                                                     #   exclusive with IsGlobal.
         IsGlobal              => 1,                 # Define a search for settings don't belong an user,
                                                     #   exclusive with TargetUserID.
     );


Returns:


.. code-block:: perl

     %ModifiedSetting = (
         ModifiedID             => "123",
         DefaultID              => 456,
         Name                   => "ProductName",
         IsGlobal               => 1,     # 1 or 0, optional
         IsValid                => 1,     # 1 or 0, optional, modified 0
         IsDirty                => 1,     # 1 or 0, optional, modified 0
         ResetToDefault         => 1,     # 1 or 0, optional, modified 0
         UserModificationActive => 0,     # 1 or 0, optional, modified 0
         EffectiveValue         => $SettingEffectiveValue,
         TargetUserID           => 2,     # ID of the user for which the modified setting is meant
         CreateTime             => "2016-05-29 11:04:04",
         CreateBy               => 1,
         ChangeTime             => "2016-05-29 11:04:04",
         ChangeBy               => 1,
         SettingUID             => 'Modified12320160529110404',
     );



ModifiedSettingListGet()
========================


Get modified setting list with complete data.


.. code-block:: perl

     my @List = $SysConfigDBObject->ModifiedSettingListGet(
         IsInvisible            => 1,                 # 1 or 0
         IsReadonly             => 0,                 # 1 or 0
         IsRequired             => 1,                 # 1 or 0
         IsValid                => 1,                 # 1 or 0
         IsDirty                => 1,                 # 1 or 0
         ResetToDefault         => 1,                 # 1 or 0
         TargetUserID           => 2,                 # the ID of the user for which the modified setting is meant,
                                                      # exclusive with IsGlobal.
         IsGlobal               => 1,                 # Define a search for settings don't belong an user,
                                                      #   exclusive with TargetUserID.
         HasConfigLevel         => 0,                 # 1 or 0
         UserModificationActive => 0,                 # 1 or 0
         Name                   => 'ACL::CacheTTL',   # setting name
         ChangeBy               => 123,
     );


Returns:


.. code-block:: perl

     @List = (
         {
             ModifiedID              => 123,
             Name                    => "ProductName",
             Description             => "Defines the name of the application ...",
             Navigation              => "ASimple::Path::Structure",
             IsInvisible             => 1,
             IsReadonly              => 0,
             IsRequired              => 1,
             IsValid                 => 1,
             ResetToDefault         => 1,                 # 1 or 0
             HasConfigLevel          => 200,
             UserModificationActive  => 0,       # 1 or 0
             XMLContentRaw           => "The XML structure as it is on the config file",
             XMLContentParsed        => "XML parsed to Perl",
             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",
             ChangeTime              => "2016-05-29 11:04:04",
         },
         {
             ModifiedID => 321,
             Name       => 'FieldName',
             # ...
             CreateTime => '2010-09-11 10:08:00',
             ChangeTime => '2011-01-01 01:01:01',
         },
         # ...
     );



ModifiedSettingDelete()
=======================


Delete a modified setting from list.


.. code-block:: perl

     my $Success = $SysConfigDBObject->ModifiedSettingDelete(
         ModifiedID => 123,
     );


Returns:


.. code-block:: perl

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



ModifiedSettingUpdate()
=======================


Update SysConfig modified.


.. code-block:: perl

     my $Success = $SysConfigDBObject->ModifiedSettingUpdate(
         ModifiedID             => 123,                           # (required)
         DefaultID              => 456,                           # (required)
         Name                   => "ProductName",                 # (required)
         IsValid                => 1,                             # (optional) 1 or 0, optional (uses the value from DefaultSetting if not defined)
         IsDirty                => 1,                             # (optional) Default 1.
         ResetToDefault         => 1,                             # (optional), default 0
         UserModificationActive => 1,                             # (optional) 1 or 0 (uses the value from DefaultSetting if not defined)
         EffectiveValue         => $SettingEffectiveValue,
         TargetUserID           => 2,                             # (optional), ID of the user for which the modified setting is meant,
                                                                  #   leave it undef for global changes.
         ExclusiveLockGUID      => $LockingString,                # the GUID used to locking the setting
         UserID                 => 1,                             # (required)
     );


Returns:


.. code-block:: perl

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



ModifiedSettingDirtyCleanUp()
=============================


Removes the IsDirty flag from modified settings.


.. code-block:: perl

     my $Success = $SysConfigDBObject->ModifiedSettingDirtyCleanUp(
         TargetUserID => 123,        # (optional)
         ModifiedIDs     => [        # (optional) applies to only this list of settings
             123,
             456,
         ],
     );


Returns:


.. code-block:: perl

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



ModifiedSettingVersionAdd()
===========================


Add a new SysConfig modified version entry.


.. code-block:: perl

     my $ModifiedVersionID = $SysConfigDBObject->ModifiedSettingVersionAdd(
         DefaultVersionID       => 456,
         Name                   => "ProductName",
         IsValid                => 1,                             # 1 or 0, optional, optional 0
         UserModificationActive => 0,                             # 1 or 0, optional, optional 0
         TargetUserID           => 2,                             # The ID of the user for which the modified setting is meant,
                                                                  # leave it undef for global changes.
         EffectiveValue         => $SettingEffectiveValue,        # the value as will be stored in the Perl configuration file
         DeploymentTimeStamp    => '2015-12-12 12:00:00',         # unique timestamp per deployment
         ResetToDefault         => 1,                             # optional, default 0
         UserID                 => 1,
     );


Returns:


.. code-block:: perl

     my $ModifiedVersionID = 123;  # false in case of an error



ModifiedSettingVersionGet()
===========================


Get SysConfig modified version entry.


.. code-block:: perl

     my %ModifiedSettingVersion = $SysConfigDBObject->ModifiedSettingVersionGet(
         ModifiedVersionID => 123,
     );


Returns:


.. code-block:: perl

     %ModifiedSetting = (
         ModifiedVersionID      => 123,
         DefaultVersionID       => 456,
         Name                   => "ProductName",
         TargetUserID           => 123,
         IsValid                => 1,         # 1 or 0
         ResetToDefault         => 1,         # 1 or 0
         UserModificationActive => 0,         # 1 or 0
         EffectiveValue         => "Product 6",
         CreateTime             => "2016-05-29 11:04:04",
         ChangeTime             => "2016-05-29 11:04:04",
     );



ModifiedSettingVersionListGet()
===============================


Get version setting list with complete data.


.. code-block:: perl

     my @List = $SysConfigDBObject->ModifiedSettingVersionListGet(
         Name              => 1, # optional
         DefaultVersionID  => 230, # optional
     );


Returns:


.. code-block:: perl

     @List = (
         {
             ModifiedVersionID      => 123,
             ModifiedID             => 456,
             Name                   => "ProductName",
             TargetUserID           => 78,
             IsValid                => 1,         # 1 or 0
             ResetToDefault         => 1,         # 1 or 0
             UserModificationActive => 0,         # 1 or 0
             EffectiveValue         => "Product 6",
             CreateTime             => "2016-05-29 11:04:04",
             ChangeTime             => "2016-05-29 11:04:04",
         },
         {
             ModifiedVersionID      => 789,
             ModifiedID             => 579,
             Name                   => "ADifferentProductName",
             TargetUserID           => 909,
             IsValid                => 1,         # 1 or 0
             ResetToDefault         => 1,         # 1 or 0
             UserModificationActive => 0,         # 1 or 0
             . . .
         },
         # ...
     );



ModifiedSettingVersionGetLast()
===============================


Get last deployment.


.. code-block:: perl

     my %ModifiedSettingVersion = $SysConfigDBObject->ModifiedSettingVersionGetLast(
         Name => 'ProductName',
     );


Returns:


.. code-block:: perl

     %ModifiedSettingVersion = (
         DefaultVersionID       => 123,
         ModifiedID             => 456,
         Name                   => "ProductName",
         TargetUserID           => 45,
         IsValid                => 1,         # 1 or 0
         ResetToDefault         => 1,         # 1 or 0
         UserModificationActive => 0,         # 1 or 0
         EffectiveValue         => "Product 6",
         CreateTime             => "2016-05-29 11:04:04",
         ChangeTime             => "2016-05-29 11:04:04",
     );



ModifiedSettingVersionListGetLast()
===================================


Get a list of the last deployed version of each modified SysConfig setting


.. code-block:: perl

     my @List = $SysConfigDBObject->ModifiedSettingVersionListGetLast();


Returns:


.. code-block:: perl

     @List = (
         {
             ModifiedVersionID      => 123,
             ModifiedID             => 456,
             Name                   => "ProductName",
             TargetUserID           => 78,
             IsValid                => 1,         # 1 or 0
             ResetToDefault         => 1,         # 1 or 0
             UserModificationActive => 0,         # 1 or 0
             EffectiveValue         => "Product 6",
             CreateTime             => "2016-05-29 11:04:04",
             ChangeTime             => "2016-05-29 11:04:04",
         },
         {
             ModifiedVersionID      => 789,
             ModifiedID             => 579,
             Name                   => "ADifferentProductName",
             TargetUserID           => 909,
             IsValid                => 1,         # 1 or 0
             ResetToDefault         => 1,         # 1 or 0
             UserModificationActive => 0,         # 1 or 0
             . . .
         },
         # ...
     );



ModifiedSettingVersionDelete()
==============================


Delete a modified setting version from list based on modified version ID or modified ID.


.. code-block:: perl

     my $Success = $SysConfigDBObject->ModifiedSettingVersionDelete(
         ModifiedVersionID => 123,
     );


or


.. code-block:: perl

     my $Success = $SysConfigDBObject->ModifiedSettingVersionDelete(
         ModifiedID => 45,
     );


or


.. code-block:: perl

     my $Success = $SysConfigDBObject->ModifiedSettingVersionDelete(
         Name => 'AnyName',
     );


Returns:


.. code-block:: perl

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



ConfigurationIsDirty()
======================


Check if there are not deployed changes on system configuration.


.. code-block:: perl

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


Returns:


.. code-block:: perl

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



DeploymentAdd()
===============


Adds a new deployment.


.. code-block:: perl

     my $DeploymentID = $SysConfigDBObject->DeploymentAdd(
         Comments            => 'Some Comments',              # optional
         EffectiveValueStrg  => $EffectiveValuesStrgRef,      # string reference with the value of all settings,
                                                              #   to be stored in a Perl cache file
         TargetUserID        => 123,                          # to deploy only user specific settings
         ExclusiveLockGUID   => $LockingString,               # the GUID used to locking the deployment,
                                                              #      not needed if TargetUserID is used
         DeploymentTimeStamp => '1977-12-12 12:00:00',
         UserID              => 123,
     );


Returns:


.. code-block:: perl

     $DeploymentID = 123;        # or false in case of an error



DeploymentGet()
===============


Gets deployment information.


.. code-block:: perl

     my %Deployment = $SysConfigDBObject->DeploymentGet(
         DeploymentID => 123,
         Valid        => 1,      # optional (this is deprecated and will be removed in next mayor release).
     );


Returns:


.. code-block:: perl

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



DeploymentListGet()
===================


Get global deployment list with complete data.


.. code-block:: perl

     my @List = $SysConfigDBObject->DeploymentListGet();


Returns:


.. code-block:: perl

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



DeploymentUserList()
====================


Get DeploymentID -> UserID list of all user deployments.


.. code-block:: perl

     my %List = $SysConfigDBObject->DeploymentUserList();


Returns:


.. code-block:: perl

     %List = {
         9876 => 123,
         5432 => 456,
         # ...
     };



DeploymentGetLast()
===================


Get last global deployment.


.. code-block:: perl

     my %Deployment = $SysConfigDBObject->DeploymentGetLast();


Returns:


.. code-block:: perl

     %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,
     );



DeploymentDelete()
==================


Delete a deployment from the database.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DeploymentDelete(
         DeploymentID => 123,
     );


Returns:


.. code-block:: perl

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



DeploymentLock()
================


Lock global deployment to a particular user.


.. code-block:: perl

     my $ExclusiveLockGUID = $SysConfigDBObject->DeploymentLock(
         UserID            => 123,
         ExclusiveLockGUID => $LockingString,    # optional (if specific GUID is needed)
         Force             => 1,                 # Optional, locks the deployment even if is already
                                                 #   locked to another user, also removes locks for
                                                 #   all settings.
     );


Returns:


.. code-block:: perl

     $ExclusiveLockGUID = 'SomeLockingString';   # or false in case of an error or already locked



DeploymentIsLocked()
====================


Check if global deployment is locked.


.. code-block:: perl

     my $Locked = $SysConfigDBObject->DeploymentIsLocked();


Returns:


.. code-block:: perl

    $Locked = 1;     # or false if it is not locked



DeploymentIsLockedByUser()
==========================


Check if global deployment is locked for a determined user.


.. code-block:: perl

     my $LockedByUser = $SysConfigDBObject->DeploymentIsLockedByUser(
         ExclusiveLockGUID => $LockingString,    # the GUID used to locking the deployment
         UserID            => 123,               # the user should have locked the deployment
     );


Returns:


.. code-block:: perl

     $LockedByUser = 'SomeLockingString';    # or false in case of not locked



DeploymentModifiedVersionList()
===============================


Return a list of modified versions for a global deployment based on the deployment time. Limited
to a particular deployment or including also all previous deployments


.. code-block:: perl

     my %ModifiedVersionList = $SysConfigDBObject->DeploymentModifiedVersionList(
         DeploymentID => 123,        # the deployment id
         Mode         => 'Equals',   # (optional) default 'Equals'
                                     #   Equals: only the settings from the given deployment
                                     #   GreaterThan: only the settings after the given deployment
                                     #   GreaterThanEquals: includes the settings of the given deployment and after
                                     #   SmallerThan: only the settings before the given deployment
                                     #   SmallerThanEquals: includes the settings of the given deployment and before
     );


Returns:


.. code-block:: perl

     %ModifiedVersionIDs = (
         123 => 'Setting1',
         124 => 'Setting2',
         125 => 'Setting3'
     );



DeploymentUnlock()
==================


Unlock global deployment.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DeploymentUnlock(
         ExclusiveLockGUID => '12ad34f21b',
         UserID            => 123,
     );


or


.. code-block:: perl

     my $Success = $SysConfigDBObject->DeploymentUnlock(
         All  => 1,
     );


Returns:


.. code-block:: perl

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



DeploymentListCleanup()
=======================


Removes invalid deployments from the database.


.. code-block:: perl

     my $Success = $SysConfigDBObject->DeploymentListCleanup( );


Returns:


.. code-block:: perl

     $Success = 1;       # Returns 1 if all records are valid (or all invalid was removed)
                         # Returns -1 if there is an invalid deployment that could be in adding process
                         # Returns false in case of an error




*****************
PRIVATE INTERFACE
*****************


_DeploymentLockGet()
====================


Get deployment lock entry.


.. code-block:: perl

     my %DeploymentLock = $SysConfigDBObject->_DeploymentLockGet();


Returns:


.. code-block:: perl

     %DeploymentLock = (
         DeploymentLoclID        => "123",
         ExclusiveLockGUID       => $LockingString,
         ExclusiveLockUserID     => 1,
         ExclusiveLockExpiryTime => '2016-05-29 11:09:04',
         CreateTime              => "2016-05-29 11:04:04",
     );



_BulkInsert()
=============


Add batch entries to the DB into a given table.


.. code-block:: perl

     my $Success = $SysConfigDBObject->_BulkInsert(
         Table   => 'table_name',    # (required) Table name
         Columns => [                # (required) Array of column names
             'column_name',
             # ...
         ],
         Data    => [                # (required) AoA with data
             [
                 'record 1',
                 'record 2',
             ],
             [
                # ...
             ],
             # ...
         ],
     );



_GetUID()
=========


Generates a unique identifier.


.. code-block:: perl

     my $UID = $TicketNumberObject->_GetUID();


Returns:


.. code-block:: perl

     my $UID = 14906327941360ed8455f125d0450277;





