<?php

/**
 * This Software is the property of Data Development and is protected
 * by copyright law - it is NOT Freeware.
 *
 * Any unauthorized use of this software without a valid license
 * is a violation of the license agreement and will be prosecuted by
 * civil and criminal law.
 *
 * https://www.d3data.de
 *
 * @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
 * @author    D3 Data Development - Daniel Seifert <support@shopmodule.com>
 * @link      https://www.oxidmodule.com
 */

declare(strict_types = 1);

namespace D3\Usermanager\Setup;

use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
use D3\ModCfg\Application\Model\d3bitmask;
use D3\ModCfg\Application\Model\d3database;
use D3\ModCfg\Application\Model\d3str;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ParameterNotFoundException;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use D3\ModCfg\Application\Model\Install\d3install_updatebase;
use D3\ModCfg\Application\Model\Installwizzard\d3installdbrecord;
use Doctrine\DBAL\DBALException;
use Exception;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Exception\ConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Application\Model\Shop;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Facts\Facts;
use ReflectionException;

class d3usermanager_update extends d3install_updatebase
{
    public $sModKey = 'd3usermanager';
    public $sModName = 'Kundenmanager';
    public $sModVersion = '4.1.2.2';
    public $sModRevision = '4122';
    public $sBaseConf = 
    'CUEv2==dW5aa2hoY3dRODVvdTJWdUJZK3RtckdSMm5PczVmN282WXNnWE9pTFUrdzVyS0FPRERObkJRU
2FGQ1d1TmJCbTd4UTlnc2N3eEVUR3dLdzdTRjllSHhKWll6WTBvMUVBMTBTYmwxOEgyaXZLK3U5bkVXT
nI4Zys4WTB3SUNxUkZhK1RhZVg1ZmYvYU5HaUgvdU1hd1RGT1pkWkI5MEpRa3h4a2ZhbEZtOTllUm5MT
m1ZSENOWlQ2ZHU2NGV1RzFidWJrZUZUOGpsVTJqK3BKMTAwa0h4UDhMaWdnWjQwNi9XbUltbzdvdytEU
C9sckJ6NWJyVm1YREt3WXJpR3F3SmxZcndyS29OelpuRnBaLzQycUtVUERlUkhNT0FjYTYrNWZCSEZ5a
jhNRXNzNy9DR1FRZWZDMkJXSGhrU3J6NmZUK2F0YS9Oa1U5anFFTHVYY2ZMaDJnPT0=';
    public $sRequirements = '';
    public $sBaseValue = 'TyUzQTglM0ElMjJzdGRDbGFzcyUyMiUzQTYlM0ElN0JzJTNBMjMlM0ElMjJkM19jZmdfbW9kX19hRm9sZGVyTGlzdCUyMiUzQmElM0E0JTNBJTdCaSUzQTAlM0JzJTNBMjMlM0ElMjJEM19VU0VSTUFOQUdFUl9VU0VSX05FVyUyMiUzQmklM0ExJTNCcyUzQTMwJTNBJTIyRDNfVVNFUk1BTkFHRVJfVVNFUl9FWFRSQUNUSU9OJTIyJTNCaSUzQTIlM0JzJTNBMjklM0ElMjJEM19VU0VSTUFOQUdFUl9VU0VSX1JFVEVOVElPTiUyMiUzQmklM0EzJTNCcyUzQTMxJTNBJTIyRDNfVVNFUk1BTkFHRVJfVVNFUl9NQUlOVEVOQU5DRSUyMiUzQiU3RHMlM0EyNCUzQSUyMmQzX2NmZ19tb2RfX2JsQ3JvbkFjdGl2ZSUyMiUzQnMlM0ExJTNBJTIyMCUyMiUzQnMlM0EyMyUzQSUyMmQzX2NmZ19tb2RfX2lNYXhVc2VyQ250JTIyJTNCcyUzQTIlM0ElMjI1MCUyMiUzQnMlM0EyNSUzQSUyMmQzX2NmZ19tb2RfX3NDcm9uUGFzc3dvcmQlMjIlM0JzJTNBMCUzQSUyMiUyMiUzQnMlM0EyOCUzQSUyMmQzX2NmZ19tb2RfX2FMaWNlbnNlSW5mb01haWwlMjIlM0JhJTNBMSUzQSU3QnMlM0E0MiUzQSUyMk5PTElDS0VZX180NzkzNjM4NzAyYjY3NzE1ZjFkZmJmYzgzMjQ2NjkxNCUyMiUzQnMlM0ExOSUzQSUyMjIwMjAtMTAtMTIlMjAwOSUzQTE2JTNBMDglMjIlM0IlN0RzJTNBMzAlM0ElMjJkM19jZmdfbW9kX19ibENhbGNTdGF0T25EZW1hbmQlMjIlM0JzJTNBMSUzQSUyMjAlMjIlM0IlN0Q=';

    public $sMinModCfgVersion = '5.3.6.0';

    protected $_aUpdateMethods = array(
        array('check' => 'doesUser2UserManagerTableNotExist',
              'do'    => 'addUser2UserManagerTable'),
        array('check' => 'doesModCfgItemNotExist',
              'do'    => 'addModCfgItem'),
        array('check' => 'checkFields',
              'do'    => 'fixFields'),
        array('check' => 'checkIndizes',
              'do'    => 'fixIndizes'),
        array('check' => 'checkCronPasswordSet',
              'do'    => 'createCronPassword'),
        array('check' => 'needExampleJobList',
              'do'    => 'addExampleJobList'),
        array('check' => 'isExampleContentMissingInDatabase',
              'do'    => 'addExampleContentList'),
        array('check' => 'requireExample2ShopRelation',
              'do'    => 'addExample2ShopRelation'),
        array('check' => 'hasUnregisteredFiles',
              'do'    => 'showUnregisteredFiles'),
        array('check' => 'checkModCfgSameRevision',
              'do'    => 'updateModCfgSameRevision'),
    );

    // Standardwerte für checkMultiLangTables() und fixRegisterMultiLangTables()
    public $aMultiLangTables = array();

    public $aFields = array(
        'PROF_EXECMANUALLY'        => array(
            'sTableName'  => 'd3modprofile',
            'sFieldName'  => 'D3_UM_EXECMANUALLY',
            'sType'       => 'TINYINT(1)',
            'blNull'      => false,
            'sDefault'    => '0',
            'sComment'    => 'user manager: job is manually executable',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'PROF_USERSAVETRIGGERED'        => array(
            'sTableName'  => 'd3modprofile',
            'sFieldName'  => 'D3_UM_USERSAVETRIGGERED',
            'sType'       => 'TINYINT(1)',
            'blNull'      => false,
            'sDefault'    => '0',
            'sComment'    => 'user manager: job will executed on user::save',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'PROF_ORDERFINISHTRIGGERED'        => array(
            'sTableName'  => 'd3modprofile',
            'sFieldName'  => 'D3_UM_ORDERFINISHTRIGGERED',
            'sType'       => 'TINYINT(1)',
            'blNull'      => false,
            'sDefault'    => '0',
            'sComment'    => 'user manager: job will executed after order::finalizeOrder',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'PROF_MARKUSER'        => array(
            'sTableName'  => 'd3modprofile',
            'sFieldName'  => 'D3_UM_MARKUSER',
            'sType'       => 'TINYINT(1)',
            'blNull'      => false,
            'sDefault'    => '0',
            'sComment'    => 'user manager: mark users as finished',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'PROF_CRONJOBID'        => array(
            'sTableName'  => 'd3modprofile',
            'sFieldName'  => 'D3_CRONJOBID',
            'sType'       => 'VARCHAR(8)',
            'blNull'      => false,
            'sDefault'    => 0,
            'sComment'    => 'ID for identifying via cronjob',
            'sExtra'      => '',
            'blMultilang' => false,
        ),

        'O_OXID'    => array(
            'sTableName'  => 'd3user2usermanager',
            'sFieldName'  => 'OXID',
            'sType'       => 'CHAR(32)',
            'blNull'      => false,
            'sDefault'    => false,
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'O_OXUSERID'    => array(
            'sTableName'  => 'd3user2usermanager',
            'sFieldName'  => 'OXUSERID',
            'sType'       => 'CHAR(32)',
            'blNull'      => false,
            'sDefault'    => false,
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'O_OXUSERMANAGERID'    => array(
            'sTableName'  => 'd3user2usermanager',
            'sFieldName'  => 'OXUSERMANAGERID',
            'sType'       => 'CHAR(32)',
            'blNull'      => false,
            'sDefault'    => false,
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'O_OXREMARKID'    => array(
            'sTableName'  => 'd3user2usermanager',
            'sFieldName'  => 'OXREMARKID',
            'sType'       => 'CHAR(32)',
            'blNull'      => false,
            'sDefault'    => false,
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'O_OXEXECDATE'    => array(
            'sTableName'  => 'd3user2usermanager',
            'sFieldName'  => 'OXEXECDATE',
            'sType'       => 'TIMESTAMP',
            'blNull'      => false,
            'sDefault'    => 'CURRENT_TIMESTAMP',
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'O_OXDONTUSEFORCHECK'    => array(
            'sTableName'  => 'd3user2usermanager',
            'sFieldName'  => 'OXDONTUSEFORCHECK',
            'sType'       => 'TINYINT(1)',
            'blNull'      => false,
            'sDefault'    => '0',
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
        'OXREMARKTYPE'    => array(
            'sTableName'  => 'oxremark',
            'sFieldName'  => 'OXTYPE',
            'sType'       => 'ENUM("d3um")',
            'blNull'      => false,
            'sDefault'    => 'r',
            'sComment'    => '',
            'sExtra'      => '',
            'blMultilang' => false,
        ),
    );

    public $aIndizes = array(
        'MP_D3_UM_EXECMANUALLY' => array(
            'sTableName' => 'd3modprofile',
            'sType'      => d3database::INDEX_TYPE_INDEX,
            'sName'      => 'D3_UM_EXECMANUALLY',
            'aFields'    => array(
                'D3_UM_EXECMANUALLY' => 'D3_UM_EXECMANUALLY',
            ),
        ),
        'MP_D3_UM_USERSAVETRIGGERED' => array(
            'sTableName' => 'd3modprofile',
            'sType'      => d3database::INDEX_TYPE_INDEX,
            'sName'      => 'D3_UM_USERSAVETRIGGERED',
            'aFields'    => array(
                'D3_UM_USERSAVETRIGGERED' => 'D3_UM_USERSAVETRIGGERED',
            ),
        ),
        'MP_D3_UM_ORDERFINISHTRIGGERED' => array(
            'sTableName' => 'd3modprofile',
            'sType'      => d3database::INDEX_TYPE_INDEX,
            'sName'      => 'D3_UM_ORDERFINISHTRIGGERED',
            'aFields'    => array(
                'D3_UM_ORDERFINISHTRIGGERED' => 'D3_UM_ORDERFINISHTRIGGERED',
            ),
        ),
        'O_OXID' => array(
            'sTableName' => 'd3user2usermanager',
            'sType'      => d3database::INDEX_TYPE_PRIMARY,
            'sName'      => 'PRIMARY',
            'aFields'    => array(
                'OXID' => 'OXID',
            ),
        ),
        'O2UM_OXUSERMANAGERID' => array(
            'sTableName' => 'd3user2usermanager',
            'sType'      => d3database::INDEX_TYPE_INDEX,
            'sName'      => 'OXUSERMANAGERID',
            'aFields'    => array(
                'OXUSERMANAGERID' => 'OXUSERMANAGERID',
            ),
        ),
        'O2UM_OXUSERID' => array(
            'sTableName' => 'd3user2usermanager',
            'sType'      => d3database::INDEX_TYPE_INDEX,
            'sName'      => 'OXUSERID',
            'aFields'    => array(
                'OXUSERID' => 'OXUSERID',
            ),
        ),
    );

    protected $_aRefreshMetaModuleIds = array('d3usermanager');

    /**
     * @return bool
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function doesUser2UserManagerTableNotExist(): bool
    {
        return $this->_checkTableNotExist('d3user2usermanager');
    }

    /**
     * @return bool
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws ConnectionException
     */
    public function addUser2UserManagerTable(): bool
    {
        $blRet = false;
        if ($this->doesUser2UserManagerTableNotExist()) {
            $this->setInitialExecMethod(__METHOD__);
            $blRet  = $this->_addTable2(
                'd3user2usermanager',
                $this->aFields,
                $this->aIndizes,
                'user to usermanageritem assignment',
                'MyISAM'
            );
        }

        return $blRet;
    }

    /**
     * @return d3installdbrecord
     * @throws Exception
     */
    public function d3GetInstallDbRecord(): d3installdbrecord
    {
        d3GetModCfgDIC()->set(
            d3installdbrecord::class.'.arg_updatebase',
            $this
        );

        /** @var d3installdbrecord $dbRecord */
        $dbRecord = d3GetModCfgDIC()->get(d3installdbrecord::class);
        return $dbRecord;
    }

    /**
     * required for unitTests
     * @return Config
     * @throws Exception
     */
    public function d3GetConfig(): Config
    {
        /** @var Config $config */
        $config = d3GetModCfgDIC()->get('d3ox.usermanager.'.Config::class);
        return $config;
    }

    /**
     * @return bool
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws Exception
     */
    public function doesModCfgItemNotExist(): bool
    {
        $blRet = false;
        foreach ($this->d3GetConfig()->getShopIds() as $sShopId) {
            $aWhere = array(
                'oxmodid'       => $this->sModKey,
                'oxnewrevision' => $this->sModRevision,
                'oxshopid'      => $sShopId,
            );

            $blRet = $this->d3GetInstallDbRecord()->checkTableRecordNotExist('d3_cfg_mod', $aWhere);

            if ($blRet == true) {
                return true;
            }
        }

        return $blRet;
    }

    /**
     * @return bool
     * @throws ConnectionException
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function addModCfgItem(): bool
    {
        $blRet = false;

        if ($this->doesModCfgItemNotExist()) {
            foreach ($this->d3GetConfig()->getShopIds() as $sShopId) {
                $aWhere = array(
                    'oxmodid'       => $this->sModKey,
                    'oxshopid'      => $sShopId,
                    'oxnewrevision' => $this->sModRevision,
                );

                if ($this->d3GetInstallDbRecord()->checkTableRecordNotExist('d3_cfg_mod', $aWhere)) {
                    // update don't use this property
                    unset($aWhere['oxnewrevision']);

                    $aInsertFields = array(
                        array (
                            'fieldname'     => 'OXID',
                            'content'       => "md5('" . $this->sModKey . " " . $sShopId . " de')",
                            'force_update'  => true,
                            'use_quote'     => false,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXSHOPID',
                            'content'       => $sShopId,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXMODID',
                            'content'       => $this->sModKey,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXNAME',
                            'content'       => $this->sModName,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXACTIVE',
                            'content'       => "0",
                            'force_update'  => false,
                            'use_quote'     => false,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXBASECONFIG',
                            'content'       => $this->sBaseConf,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXSERIAL',
                            'content'       => "",
                            'force_update'  => false,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXINSTALLDATE',
                            'content'       => "NOW()",
                            'force_update'  => true,
                            'use_quote'     => false,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXVERSION',
                            'content'       => $this->sModVersion,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXSHOPVERSION',
                            'content'       => oxNew(Facts::class)->getEdition(),
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array (
                            'fieldname'     => 'OXREQUIREMENTS',
                            'content'       => $this->sRequirements,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array(
                            'fieldname'     => 'OXVALUE',
                            'content'       => $this->sBaseValue,
                            'force_update'  => false,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        ),
                        array(
                            'fieldname'     => 'OXNEWREVISION',
                            'content'       => $this->sModRevision,
                            'force_update'  => true,
                            'use_quote'     => true,
                            'use_multilang' => false,
                        )
                    );

                    $this->setInitialExecMethod(__METHOD__);
                    $blRet  = $this->_updateTableItem2('d3_cfg_mod', $aInsertFields, $aWhere);

                    if ($this->getStepByStepMode()) {
                        break;
                    }
                }
            }
        }
        return $blRet;
    }

    /**
     * @return bool true, if new password must set
     */
    public function checkCronPasswordSet(): bool
    {
        /** @var d3_cfg_mod $set */
        $set = d3GetModCfgDIC()->get('d3.usermanager.modcfg');
        $password = $set->getValue('sCronPassword');
        return false === $password || is_null($password) || (is_string($password) && strlen($password) <= 0);
    }

    /**
     * @return bool
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws StandardException
     * @throws d3ShopCompatibilityAdapterException
     * @throws d3_cfg_mod_exception
     */
    public function createCronPassword(): bool
    {
        $message = Registry::getLang()->translateString('D3_USERMANAGER_SETUP_CRONPASSWORD') . PHP_EOL.PHP_EOL;
        $this->setActionLog('msg', $message, __METHOD__);

        if ($this->hasExecute()) {
            /** @var d3str $oD3str */
            $oD3str = d3GetModCfgDIC()->get(d3str::class);
            $password = $oD3str->random_str(12);

            /** @var d3_cfg_mod $set */
            $set = d3GetModCfgDIC()->get('d3.usermanager.modcfg');
            $set->setValue('sCronPassword', $password);
            $set->saveNoLicenseRefresh();
        }

        return true;
    }

    /**
     * @return bool true, if update is required
     * @throws DBALException
     * @throws Exception
     */
    public function needExampleJobList(): bool
    {
        $blRet = false;

        /** @var d3database $db */
        $db = d3GetModCfgDIC()->get('d3.usermanager.database');
        $qb = $db->getQueryBuilder();
        // change this to your inividual check criterias
        $qb->select('count(oxid) ')->from('d3modprofile')
           ->where('oxmodid = '.$qb->createNamedParameter('d3usermanager'))
           ->setMaxResults(1);

        if ($qb->execute()->fetchColumn() == 0) {
            $blRet = true;
        }

        return $blRet;
    }

    /**
     * @return bool
     * @throws ConnectionException
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function addExampleJobList(): bool
    {
        $blRet = true;

        foreach ($this->getExampleJobInsertList() as $aJobContentInfos) {
            $blRet = $this->_addExampleJobItem($aJobContentInfos['table'], $aJobContentInfos['content']);

            if (false == $blRet) {
                break;
            }
        }

        $this->setUpdateBreak(true);

        return $blRet;
    }

    /**
     * @return bool true, if update is required
     * @throws Exception
     */
    public function isExampleContentMissingInDatabase(): bool
    {
        $blRet = false;

        $aIdentList = [];
        foreach ($this->getExampleContentInsertList() as $aJobContentInfos) {
            $aInsertFields = $this->{$aJobContentInfos['content']}($this->d3GetConfig()->getActiveShop());
            foreach ($aInsertFields as $aInsertField) {
                if (is_string($aInsertField['fieldname']) && strtoupper($aInsertField['fieldname']) == 'OXLOADID') {
                    $aIdentList[] = $aInsertField['content'];
                }
            }
        }

        if (count($aIdentList)) {
            // change this to your inividual check criterias
            /** @var d3database $db */
            $db = d3GetModCfgDIC()->get('d3.usermanager.database');
            $qb = $db->getQueryBuilder();
            $qb->select('count(oxid) < '.count($aIdentList))
                ->from('oxcontents')
                ->where(
                        $qb->expr()->in('oxloadid', implode(', ', array_map(
                            function($value) use ($qb) {
                                return $qb->createNamedParameter($value);
                            },
                            $aIdentList
                        )))
                    )
                ->setMaxResults(1);

            return (bool) $qb->execute()->fetchColumn();
        }

        return $blRet;
    }

    /**
     * @return bool
     * @throws ConnectionException
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function addExampleContentList(): bool
    {
        $blRet = true;

        foreach ($this->getExampleContentInsertList() as $aJobContentInfos) {
            $blRet = $this->_addExampleJobItem($aJobContentInfos['table'], $aJobContentInfos['content']);

            if (!$blRet) {
                break;
            }
        }

        $this->setUpdateBreak(true);

        return $blRet;
    }

    /**
     * @return bool true, if update is required
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws d3ParameterNotFoundException
     * @throws ConnectionException
     */
    public function requireExample2ShopRelation(): bool
    {
        startProfile(__METHOD__);

        $this->setInitialExecMethod(__METHOD__);

        foreach ($this->getExampleJobInsertList() as $aJobContentInfos) {
            $sGetFieldContentMethodName = $aJobContentInfos['content'];
            /** @var $oShop Shop */
            foreach ($this->getShopListByActiveModule('d3usermanager') as $oShop) {
                $aCheckFields = $this->{$sGetFieldContentMethodName}($oShop);

                if ($this->_require2ShopRelation($aJobContentInfos['table'], $aCheckFields)) {
                    stopProfile(__METHOD__);
                    return true;
                }
            }
        }

        stopProfile(__METHOD__);
        return false;
    }

    /**
     * @return bool
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws d3ParameterNotFoundException
     * @throws ConnectionException
     */
    public function addExample2ShopRelation(): bool
    {
        $blRet = true;

        foreach ($this->getExampleJobInsertList() as $aJobContentInfos) {
            $sGetFieldContentMethodName = $aJobContentInfos['content'];
            /** @var $oShop Shop */
            foreach ($this->getShopListByActiveModule('d3usermanager') as $oShop) {
                $aInsertFields = $this->{$sGetFieldContentMethodName}($oShop);
                $blRet = $this->_add2ShopRelation($aJobContentInfos['table'], $aInsertFields);
            }

            if (!$blRet) {
                break;
            }
        }

        $this->setUpdateBreak(true);

        return $blRet;
    }

    /**
     * @return array
     */
    public function getExampleJobInsertList(): array
    {
        return array(
            array(
                'content'   => 'getExampleJobItem1InsertFields',
                'table'     => 'd3modprofile'
            ),
            array(
                'content'   => 'getExampleJobItem2InsertFields',
                'table'     => 'd3modprofile'
            ),
            array(
                'content'   => 'getExampleJobItem3InsertFields',
                'table'     => 'd3modprofile'
            ),
            array(
                'content'   => 'getExampleJobItem4InsertFields',
                'table'     => 'd3modprofile'
            ),
            array(
                'content'   => 'getExampleJobItem5InsertFields',
                'table'     => 'd3modprofile'
            ),
        );
    }

    /**
     * @return array
     */
    public function getExampleContentInsertList(): array
    {
        return array(
            array(
                'content'   => 'getExampleContent1InsertFields',
                'table'     => 'oxcontents'
            ),
            array(
                'content'   => 'getExampleContent2InsertFields',
                'table'     => 'oxcontents'
            ),
        );
    }

    /**
     * @return d3bitmask
     * @throws Exception
     */
    public function getD3BitMask(): d3bitmask
    {
        /** @var d3bitmask $bitMask */
        $bitMask = d3GetModCfgDIC()->get(d3bitmask::class);
        return $bitMask;
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws Exception
     */
    public function getExampleJobItem1InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();
        $iShopBit = strlen($sShopId) == 1 ? $this->getD3BitMask()->getIntByBitPosition((int) $sShopId) : '1';

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5('" . $this->sModKey . " job01 " . $sShopId . "')",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPINCL',
                'content'       => $iShopBit,
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPEXCL',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVEFROM',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVETO',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXMODID',
                'content'       => 'd3usermanager',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => 'Newsletter-Export',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'de'),
                'content'       => 'Newsletter-Export',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'en'),
                'content'       => 'newsletter export',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHORTDESC',
                'content'       => 'Wird der Newsletterversand bei Ihnen über eine separate Software oder einen externen Dienst durchgeführt, können Sie mit dieser Aufgabe eine exportierbare Liste aller Ihrer Empfänger erstellen. Dem Listenformat sind dabei keine Grenzen gesetzt.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXSHORTDESC', 'de'),
                'content'       => 'Wird der Newsletterversand bei Ihnen über eine separate Software oder einen externen Dienst durchgeführt, können Sie mit dieser Aufgabe eine exportierbare Liste aller Ihrer Empfänger erstellen. Dem Listenformat sind dabei keine Grenzen gesetzt.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXCREATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXUPDATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXUPDATE', 'de'),
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXMODVERSION',
                'content'       => $this->sModVersion,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXLOG',
                'content'       => '15',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => true,
            ),
            array(
                'fieldname'     => 'OXVALUE',
                'content'       => ' ',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => 'D3_USERMANAGER_USER_RETENTION',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXSORT',
                'content'       => '1000',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXWRITEPROTECTION',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_EXECMANUALLY',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'D3_UM_MARKUSER',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
        );
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws Exception
     */
    public function getExampleJobItem2InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();
        $iShopBit = strlen($sShopId) == 1 ? $this->getD3BitMask()->getIntByBitPosition((int) $sShopId) : '1';

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5('" . $this->sModKey . " job02 " . $sShopId . "')",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPINCL',
                'content'       => $iShopBit,
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPEXCL',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVEFROM',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVETO',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXMODID',
                'content'       => 'd3usermanager',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => 'Geburtstagsglückwünsche',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'de'),
                'content'       => 'Geburtstagsglückwünsche',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'en'),
                'content'       => 'birthday wishes',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHORTDESC',
                'content'       => 'Senden Sie den Geburtstagskindern unter Ihren Kunden einen personalisierten Glückwunsch. Dies ruft Ihren Shop wieder ins Gedächtnis und macht Freude.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXSHORTDESC', 'de'),
                'content'       => 'Senden Sie den Geburtstagskindern unter Ihren Kunden einen personalisierten Glückwunsch. Dies ruft Ihren Shop wieder ins Gedächtnis und macht Freude.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXCREATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXUPDATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXUPDATE', 'de'),
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXMODVERSION',
                'content'       => $this->sModVersion,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXLOG',
                'content'       => '15',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => true,
            ),
            array(
                'fieldname'     => 'OXVALUE',
                'content'       => ' ',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => 'D3_USERMANAGER_USER_RETENTION',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXSORT',
                'content'       => '2000',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXWRITEPROTECTION',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_EXECMANUALLY',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_MARKUSER',
                'content'       => '1',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
        );
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function getExampleJobItem3InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();
        $iShopBit = strlen($sShopId) == 1 ? $this->getD3BitMask()->getIntByBitPosition((int) $sShopId) : '1';

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5('" . $this->sModKey . " job03 " . $sShopId . "')",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPINCL',
                'content'       => $iShopBit,
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPEXCL',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVEFROM',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVETO',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXMODID',
                'content'       => 'd3usermanager',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => 'Stammkunden-Zuordnung',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'de'),
                'content'       => 'Stammkunden-Zuordnung',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'en'),
                'content'       => 'assign patrons',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHORTDESC',
                'content'       => 'Premiumkunden (hohe Bestellanzahl und gute Bonität) werden in spezielle Kundengruppe verschoben, um z.B. zusätzliche Kaufanreize zu ermöglichen.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXSHORTDESC', 'de'),
                'content'       => 'Premiumkunden (hohe Bestellanzahl und gute Bonität) werden in spezielle Kundengruppe verschoben, um z.B. zusätzliche Kaufanreize zu ermöglichen.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXCREATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXUPDATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXUPDATE', 'de'),
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXMODVERSION',
                'content'       => $this->sModVersion,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXLOG',
                'content'       => '15',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => true,
            ),
            array(
                'fieldname'     => 'OXVALUE',
                'content'       => ' ',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => 'D3_USERMANAGER_USER_MAINTENANCE',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXSORT',
                'content'       => '3000',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXWRITEPROTECTION',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_EXECMANUALLY',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_MARKUSER',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
        );
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws Exception
     */
    public function getExampleJobItem4InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();
        $iShopBit = strlen($sShopId) == 1 ? $this->getD3BitMask()->getIntByBitPosition((int) $sShopId) : '1';

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5('" . $this->sModKey . " job04 " . $sShopId . "')",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPINCL',
                'content'       => $iShopBit,
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPEXCL',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVEFROM',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVETO',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXMODID',
                'content'       => 'd3usermanager',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => 'Bestellabbrecher reaktivieren',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'de'),
                'content'       => 'Bestellabbrecher reaktivieren',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'en'),
                'content'       => 'find orderbreak',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHORTDESC',
                'content'       => 'Alle Kunden mit Kundenkonto, die noch keine Bestellung auslösten, können z.B. mit Sonderrabatten zum ersten Kauf bewegt werden. Diese Aufgabe kann durch Prüfung auf stehengelassene Warenkörbe weiter verfeinert werden.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXSHORTDESC', 'de'),
                'content'       => 'Alle Kunden mit Kundenkonto, die noch keine Bestellung auslösten, können z.B. mit Sonderrabatten zum ersten Kauf bewegt werden. Diese Aufgabe kann durch Prüfung auf stehengelassene Warenkörbe weiter verfeinert werden.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXCREATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXUPDATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXUPDATE', 'de'),
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXMODVERSION',
                'content'       => $this->sModVersion,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXLOG',
                'content'       => '15',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => true,
            ),
            array(
                'fieldname'     => 'OXVALUE',
                'content'       => ' ',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => 'D3_USERMANAGER_USER_EXTRACTION',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXSORT',
                'content'       => '4000',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXWRITEPROTECTION',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_EXECMANUALLY',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_MARKUSER',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
        );
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function getExampleJobItem5InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();
        $iShopBit = strlen($sShopId) == 1 ? $this->getD3BitMask()->getIntByBitPosition((int) $sShopId) : '1';

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5(RAND())",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPINCL',
                'content'       => $iShopBit,
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPEXCL',
                'content'       => '0',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVEFROM',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVETO',
                'content'       => '0000-00-00 00:00:00',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXMODID',
                'content'       => 'd3usermanager',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => 'Kunden segmentieren',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'de'),
                'content'       => 'Kunden segmentieren',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXTITLE', 'en'),
                'content'       => 'segment customers',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHORTDESC',
                'content'       => 'Gruppieren Sie Ihre Kunden z.B. nach gekauften Kategorieartikeln oder verwendeten Zahlarten, um diese Kunden mit gezieltem Marketing direkter ansprechen zu können. Legen Sie für jedes Segment eine entsprechende Aufgabe an.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXSHORTDESC', 'de'),
                'content'       => 'Gruppieren Sie Ihre Kunden z.B. nach gekauften Kategorieartikeln oder verwendeten Zahlarten, um diese Kunden mit gezieltem Marketing direkter ansprechen zu können. Legen Sie für jedes Segment eine entsprechende Aufgabe an.',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXCREATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXUPDATE',
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('d3modprofile', 'OXUPDATE', 'de'),
                'content'       => 'NOW()',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXMODVERSION',
                'content'       => $this->sModVersion,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXLOG',
                'content'       => '15',
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => true,
            ),
            array(
                'fieldname'     => 'OXVALUE',
                'content'       => ' ',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => '',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array(
                'fieldname'     => 'OXSORT',
                'content'       => '5000',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXWRITEPROTECTION',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_EXECMANUALLY',
                'content'       => "0",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'D3_UM_MARKUSER',
                'content'       => '1',
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
        );
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function getExampleContent1InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5('" . $this->sModKey . " content01 " . $sShopId . "')",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXLOADID',
                'content'       => "d3orderbreakhtml",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSNIPPET',
                'content'       => "1",
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTYPE',
                'content'       => "0",
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXPOSITION',
                'content'       => "",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => "Bestellabbruch",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('oxcontents', 'OXTITLE', 'de'),
                'content'       => "Bestellabbruch",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('oxcontents', 'OXTITLE', 'en'),
                'content'       => "order break",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXCONTENT',
                'content'       => "<p style='font-family: Verdana, Arial, sans-serif; font-size:11px;'>Hallo [{\$oUser->oxuser__oxsal->value|oxmultilangsal}] [{\$oUser->getFieldData('oxuser')}] [{\$oUser->getFieldData('oxlname')}],<br /><br />Wir haben uns sehr über Ihren Besuch unseres Shops gefreut.<br />Wie wir festgestellt haben, haben Sie sich als Kunde registriert,<br />dann jedoch keine Bestellung aufgegeben.<br /><br />Um unsere Services und die Abläufe in unserem Shop zu verbessern,<br />würden wir uns über Ihre Antwort zu den Gründen freuen. Vielen Dank im Voraus.<br /><br />Ihr [{\$shop->getFieldData('oxname')}]-Team<br /><br /><br />Nach der Registrierung habe ich keine Bestellung vorgenommen, weil<br /><br />[ ] Ich den/die Artikel anderswo günstiger bekommen habe<br /><br />[ ] Der/die Artikel entsprachen doch nicht meinen Vorstellungen<br /><br />[ ] Der Bestellprozess war mir zu kompliziert<br /><br />[ ] Ihr Shop war mir nicht vertrauenswürdig genug<br /><br />[ ] Nicht die Zahlungsarten angeboten werden, die ich bevorzuge. Es fehlte:<br /><br />..........................................................<br /><br />[ ] Es eine Fehlermeldung gab. Die Fehlermeldung lautete:<br /><br />..........................................................<br /><br />[ ] Es andere technische Probleme gab, und zwar:<br /><br />..........................................................<br /><br />[ ] Sonstige Gründe:<br /><br />..........................................................</p>",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXCATID',
                'content'       => "",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => "CMSFOLDER_USERINFO",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
        );
    }

    /**
     * @param Shop $oShop
     *
     * @return array
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    public function getExampleContent2InsertFields(Shop $oShop): array
    {
        $sShopId = $oShop->getId();

        return array(
            array (
                'fieldname'     => 'OXID',
                'content'       => "MD5('" . $this->sModKey . " content02 " . $sShopId . "')",
                'force_update'  => false,
                'use_quote'     => false,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXLOADID',
                'content'       => "d3orderbreakplain",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSHOPID',
                'content'       => $sShopId,
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXSNIPPET',
                'content'       => "1",
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTYPE',
                'content'       => "0",
                'force_update'  => true,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXACTIVE',
                'content'       => "1",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXPOSITION',
                'content'       => "",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXTITLE',
                'content'       => "Bestellabbruch (plain)",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('oxcontents', 'OXTITLE', 'de'),
                'content'       => "Bestellabbruch (plain)",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => $this->_getLangAbbrFieldName('oxcontents', 'OXTITLE', 'en'),
                'content'       => "order break (plain)",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXCONTENT',
                'content'       => "Hallo [{\$oUser->oxuser__oxsal->value|oxmultilangsal}] [{\$oUser->oxuser__oxfname->getRawValue()}] [{\$oUser->oxuser__oxlname->getRawValue()}],\r\n\r\nWir haben uns sehr \über Ihren Besuch unseres Shops gefreut.\r\nWie wir festgestellt haben, haben Sie sich als Kunde registriert,\r\nhaben dann jedoch keine Bestellung aufgegeben.\r\n\r\nUm unsere Services und die Abläufe in unserem Shop zu verbessern,\r\nwürden wir uns über Ihre Antwort zu den Gr\ünden freuen. Vielen Dank im Voraus.\r\n\r\nIhr [{\$shop->oxshops__oxname->getRawValue()}]-Team\r\n\r\n\r\nNach der Registrierung habe ich keine Bestellung vorgenommen, weil\r\n\r\n[ ] Ich den/die Artikel anderswo günstiger bekommen habe\r\n\r\n[ ] Der/die Artikel entsprachen doch nicht meinen Vorstellungen\r\n\r\n[ ] Der Bestellprozess war mir zu kompliziert\r\n\r\n[ ] Ihr Shop war mir nicht vertrauenswürdig genug\r\n\r\n[ ] Nicht die Zahlungsarten angeboten werden, die ich bevorzuge. Es fehlte:\r\n\r\n..........................................................\r\n\r\n[ ] Es eine Fehlermeldung gab. Die Fehlermeldung lautete:\r\n\r\n..........................................................\r\n\r\n[ ] Es andere technische Probleme gab, und zwar:\r\n\r\n..........................................................\r\n\r\n[ ] Sonstige Gründe:\r\n\r\n..........................................................",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => true,
            ),
            array (
                'fieldname'     => 'OXCATID',
                'content'       => "",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
            array (
                'fieldname'     => 'OXFOLDER',
                'content'       => "CMSFOLDER_USERINFO",
                'force_update'  => false,
                'use_quote'     => true,
                'use_multilang' => false,
            ),
        );
    }

    /**
     * @param $sTableName
     *
     * @param $sGetFieldContentMethodName
     * @return bool
     * @throws ConnectionException
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     */
    protected function _addExampleJobItem($sTableName, $sGetFieldContentMethodName): bool
    {
        $blRet = false;

        /** @var $oShop Shop */
        foreach ($this->getShopListByActiveModule('d3usermanager') as $oShop) {
            $aWhere = array();
            $aInsertFields = $this->{$sGetFieldContentMethodName}($oShop);

            $this->setInitialExecMethod(__METHOD__);
            $blRet  = $this->_updateTableItem2($sTableName, $aInsertFields, $aWhere);

            if ($this->getStepByStepMode()) {
                break;
            }
        }

        return $blRet;
    }

    /**
     * @return bool
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws StandardException
     * @throws ReflectionException
     * @throws d3ParameterNotFoundException
     * @throws d3ShopCompatibilityAdapterException
     * @throws d3_cfg_mod_exception
     */
    public function hasUnregisteredFiles(): bool
    {
        return $this->_hasUnregisteredFiles('d3usermanager', array('d3FileRegister'));
    }

    /**
     * @return bool
     * @throws DBALException
     * @throws DatabaseConnectionException
     * @throws DatabaseErrorException
     * @throws StandardException
     * @throws ReflectionException
     * @throws d3ShopCompatibilityAdapterException
     * @throws d3_cfg_mod_exception
     */
    public function showUnregisteredFiles(): bool
    {
        return $this->_showUnregisteredFiles('d3usermanager', array('d3FileRegister'));
    }
}
