Kernel::System::FocusTopics

NAME

Kernel::System::FocusTopics – focus topics lib

PUBLIC INTERFACE

Add()

Creates/adds a new user focused configuration into the database.

    my $Result = $FocusTopicsObject->Add(
        TargetUserID => 123,      # required
        Attribute    => 'Queue',  # required
        Value        => [...],    # required
        UserID       => 1,        # required
    );

Returns

    1        - in case of success.
    C<undef> - in case any error occurs.

List()

Get a list of focused user values.

    my $Values = $FocusTopicsObject->List(
        Filters => {
            UserID    => '...' # optional
            Attribute => '...' # optional
        },
    );

Returns

    C<undef> - in case any error occurs
    []       - in case no data was found
    [
        {
            UserID     => 123,
            Attribute  => 'SomeAttribute',
            Value      => [...],
            CreateTime => '2019-12-12 12:00:00',
            CreateBy   => 123,
        },
        ...
    ]

Get()

Get user-attribute focused value.

    my $Values = $UserConfigObject->Get(
        TargetUserID => '...',
        Attribute    => '...',
    );

Returns

    C<undef> - in case any error occurs
    {}       - in case no data was found
    {
        ID           => 123,
        TargetUserID => 123,
        Attribute    => 'SomeAttribute',
        Value        => [...],
        CreateTime   => '2019-12-12 12:00:00',
        CreateBy     => 123,
    },

Delete()

Delete focused user values from the database.

    # delete all focused values.
    my $Result = $FocusTopicsObject->Delete();

    # delete all focused user values from a user and a specified attribute.
    my $Result = $FocusTopicsObject->Delete(
        Filters => {
            TargetUserID => 123,
            Attribute    => 'SomeAttribute',
        },
    );

Returns

    1 - in case of success.
    C<undef> - in case any error occurs.

Update()

Updates focused user values.

    my $Result = $FocusTopicsObject->Update(
        TargetUserID => '...' # required
        Attribute    => '...' # required
        Value        => [...] # required
        UserID       => '...' # required
    );

Returns

    1 - in case of success.
    C<undef> - in case any error occurs.

PRIVATE INTERFACE

_GetDBColumnMapForParams()

Get the mapping of params to database columns.

    # mapping for all params
    my $Map = $Self->_GetDBColumnMapForParams();

    # mapping only for the needed params
    my $Map = $Self->_GetDBColumnMapForParams(
        Want => [qw( TargetUserID ConfigType )],
    );

Returns

    a map/dictionary with the param and respective column name.

_FiltersSQLAndBinds()

Builds the SQL 'WHERE' clause and value binds based on the filters.

    # something like:
    my ($SQLWhere, $Binds) = $Self->_FiltersSQLAndBinds(
        Filters => {
            TargetUserID => 999,
            ConfigType   => 'SomeConfigType',
        },
    );
    # generates:
    $SQLWhere = (user_id = ?) AND (config_type = ?)
    $Binds    = [999, 'SoeConfigType']

    # it's possible to indicate which operator to use:
    my ($SQLWhere, $Binds) = $Self->_FiltersSQLAndBinds(
        Filters => {
            ConfigType => { 'LIKE' => '*Some*'},
        },
    );
    # generates:
    $SQLWhere = (ConfigType LIKE ?)
    $Binds    = ['*Some*']

Returns

    (string, arrayref)

_List()

Get a list of focused user values directly from the database.

    my $Values =  $Self-_>List(
        Filters => {
            TargetUserID => '...' # optional
            ConfigType   => '...' # optional
        },
    );

Returns

    C<undef> - in case any error occurs
    []       - in case no data was found
    [
        {
            TargetUserID => 123,
            Attribute    => 'SomeAttribute',
            Value        => \%Config,
            CreateTime   => '2019-12-12 12:00:00',
            CreateBy     => 123,
        },
        ...
    ]

_CacheType()

Returns the cache type.

Scroll to Top