Customer DB backend - filter deleted customers?

Moderator: crythias

Locked
brandner
Znuny newbie
Posts: 10
Joined: 13 Oct 2015, 20:14
Znuny Version: 5.0.9
Real Name: Tony Brandner

Customer DB backend - filter deleted customers?

Post by brandner »

(Not intentionally cross-posted, I just think I maybe posted this to the wrong board originally. Sorry!)

Enjoying working with OTRS so far.
We are on version 4.0.11 on Ubuntu with multiple customer backend databases. Both are mysql, where one of the backend databases is read-only.

I'm trying to figure out an appropriate strategy to filter the read-only database so that fewer customer records are retrieved. The table contains deleted (archived) data and I don't want them to show up.

Essentially I want to have it use a query like - select * from ourcustomertable where deleted is null

Code: Select all

    # 2. second CustomerDB is the 'address book' functionality
    $Self->{CustomerUser2} = {
        Name   => 'Database Customer Address Book',
        Module => 'Kernel::System::CustomerUser::DB',
        Params => {
            DSN => 'DBI:mysql:database=ourdatabase;host=ourserver;',
            DatabaseUser => 'ouruser',
            DatabasePw => 'ourpassword',
            Table => 'ourcustomertable',
            CaseSensitive => 0,
            ForeignDB => 1,    # set this to 1 if your table does not have create_time, create_by, change_time and change_by fields
        },

        # customer unique id
        CustomerKey => 'customer_id',

        # customer #
        CustomerID => 'email',

        # The last field must always be the email address so that a valid
        #   email address like "John Doe" <john.doe@domain.com> can be constructed from the fields.
        CustomerUserListFields => [ 'first_name', 'last_name', 'email' ],
        CustomerUserSearchFields           => [ 'first_name', 'last_name', 'email' ],
        CustomerUserSearchPrefix           => '*',
        CustomerUserSearchSuffix           => '*',
        CustomerUserSearchListLimit        => 250,
        CustomerUserPostMasterSearchFields => ['email'],
        CustomerUserNameFields             => [ 'first_name', 'last_name' ],
        CustomerUserEmailUniqCheck         => 0,

        # cache time to live in sec. - cache any database queries
        CacheTTL => 60,
        ReadOnly => 1,
        Map => [
        # note: Login, Email and CustomerID needed!
        # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly, http-link-target, link class(es)
            [ 'UserFirstname',  'Firstname',  'first_name',  1, 1, 'var', '', 0 ],
            [ 'UserLastname',   'Lastname',   'last_name',   1, 1, 'var', '', 0 ],
            [ 'UserLogin',      'Username',   'login',       1, 1, 'var', '', 0 ],
            [ 'UserEmail',      'Email',      'email',       1, 1, 'var', '', 0 ],
            [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],
        ],

        # default selections
        Selections => {

        },
    };
Any thoughts on how I could achieve this?
Locked