2020-10-02 11:59:22 +02:00
|
|
|
<?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
|
|
|
|
*/
|
|
|
|
|
2021-03-15 15:17:45 +01:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2020-10-02 11:59:22 +02:00
|
|
|
namespace D3\Usermanager\Modules\Application\Model;
|
|
|
|
|
2020-12-21 10:44:49 +01:00
|
|
|
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
|
2020-10-02 11:59:22 +02:00
|
|
|
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3ParameterNotFoundException;
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
2021-03-15 15:17:45 +01:00
|
|
|
use D3\Usermanager\Application\Model\d3usermanager_configurationcheck;
|
|
|
|
use D3\Usermanager\Application\Model\Exceptions\d3ActionRequirementAbstract;
|
|
|
|
use D3\Usermanager\Application\Model\d3usermanager as Manager;
|
2020-10-02 11:59:22 +02:00
|
|
|
use D3\Usermanager\Application\Model\d3usermanager_conf;
|
|
|
|
use D3\Usermanager\Application\Model\d3usermanager_execute;
|
|
|
|
use D3\Usermanager\Application\Model\d3usermanagerlist;
|
2021-03-15 15:17:45 +01:00
|
|
|
use D3\Usermanager\Application\Model\Exceptions\d3usermanager_templaterendererExceptionInterface;
|
2020-10-02 11:59:22 +02:00
|
|
|
use Doctrine\DBAL\DBALException;
|
|
|
|
use Exception;
|
2021-03-15 15:17:45 +01:00
|
|
|
use OxidEsales\Eshop\Core\Config;
|
2020-10-02 11:59:22 +02:00
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
2021-03-15 15:17:45 +01:00
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
|
|
|
use OxidEsales\Eshop\Core\UtilsView;
|
2020-10-02 11:59:22 +02:00
|
|
|
|
|
|
|
class d3_user_usermanager extends d3_user_usermanager_parent
|
|
|
|
{
|
2021-03-15 15:17:45 +01:00
|
|
|
CONST PREVENTION_SAVEUSER = 'd3PreventUMSaveUserTrigger';
|
|
|
|
|
2020-10-02 11:59:22 +02:00
|
|
|
/**
|
2021-03-15 15:17:45 +01:00
|
|
|
* @param string $sParamName
|
2020-10-02 11:59:22 +02:00
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2021-03-15 15:17:45 +01:00
|
|
|
public function __get($sParamName)
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
2021-03-15 15:17:45 +01:00
|
|
|
$mContent = parent::__get($sParamName);
|
2020-10-02 11:59:22 +02:00
|
|
|
|
2021-03-15 15:17:45 +01:00
|
|
|
if (false == $mContent && $this->{$sParamName}) {
|
|
|
|
return $this->{$sParamName};
|
2020-10-02 11:59:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $mContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* required for test purposes only
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ParameterNotFoundException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
|
|
|
public function d3usermanagerTestMethod()
|
|
|
|
{
|
|
|
|
$this->assign(['oxcity' => 'TestCity']);
|
|
|
|
$this->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-15 15:17:45 +01:00
|
|
|
* @return string|false
|
2020-10-02 11:59:22 +02:00
|
|
|
* @throws d3ParameterNotFoundException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function save()
|
|
|
|
{
|
|
|
|
$blSave = parent::save();
|
|
|
|
|
2020-12-21 10:44:49 +01:00
|
|
|
/** @var d3_cfg_mod $oSet */
|
|
|
|
$oSet = d3GetModCfgDIC()->get('d3.usermanager.modcfg');
|
2021-03-15 15:17:45 +01:00
|
|
|
$currentAdminMode = $this->isAdmin();
|
|
|
|
|
|
|
|
if ($oSet->isActive() && in_array(Registry::getSession()->getVariable(self::PREVENTION_SAVEUSER), [null, false], true)) {
|
|
|
|
/** @var d3usermanagerlist $oManagerList */
|
2020-12-21 10:44:49 +01:00
|
|
|
$oManagerList = d3GetModCfgDIC()->get(d3usermanagerlist::class);
|
2021-03-15 15:17:45 +01:00
|
|
|
/** @var Manager $oManager */
|
2020-12-21 10:44:49 +01:00
|
|
|
foreach ($oManagerList->d3GetUserSaveTriggeredManagerTasks() as $oManager) {
|
2021-03-15 15:17:45 +01:00
|
|
|
try {
|
|
|
|
$this->d3UserManagerCheckForConfigurationException($oManager);
|
|
|
|
|
|
|
|
$oManagerExecute = $this->d3UsermanagerGetManagerExecute($oManager);
|
|
|
|
if ($oManagerExecute->userMeetsConditions($this->getId())) {
|
|
|
|
// prevent infinit loop because of circular reference in save::method
|
|
|
|
Registry::getSession()->setVariable(self::PREVENTION_SAVEUSER, true);
|
|
|
|
$oManagerExecute->exec4user($this->getId(), d3usermanager_conf::EXECTYPE_USERSAVETRIGGERED);
|
|
|
|
}
|
|
|
|
} catch (d3ActionRequirementAbstract $e) {
|
|
|
|
$e->debugOut();
|
|
|
|
if (true === $currentAdminMode) {
|
|
|
|
/** @var UtilsView $utilsView */
|
|
|
|
$utilsView = d3GetModCfgDIC()->get('d3ox.usermanager.' . UtilsView::class);
|
|
|
|
$utilsView->addErrorToDisplay($e);
|
|
|
|
}
|
|
|
|
} catch (d3usermanager_templaterendererExceptionInterface $e) {
|
|
|
|
$e->debugOut();
|
|
|
|
if (true === $currentAdminMode) {
|
|
|
|
/** @var UtilsView $utilsView */
|
|
|
|
$utilsView = d3GetModCfgDIC()->get('d3ox.usermanager.' . UtilsView::class);
|
|
|
|
$utilsView->addErrorToDisplay($e);
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
Registry::getSession()->setVariable(self::PREVENTION_SAVEUSER, false);
|
|
|
|
$oConfig = d3GetModCfgDIC()->get('d3ox.usermanager.'.Config::class);
|
|
|
|
$oConfig->setAdminMode($currentAdminMode);
|
2020-12-21 10:44:49 +01:00
|
|
|
}
|
2020-10-02 11:59:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $blSave;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-15 15:17:45 +01:00
|
|
|
* @param Manager $oManager
|
2020-10-02 11:59:22 +02:00
|
|
|
* @return d3usermanager_execute
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2021-03-15 15:17:45 +01:00
|
|
|
public function d3UsermanagerGetManagerExecute(Manager $oManager): d3usermanager_execute
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
|
|
|
d3GetModCfgDIC()->set(
|
|
|
|
d3usermanager_execute::class.'.args.usermanager',
|
|
|
|
$oManager
|
|
|
|
);
|
|
|
|
|
|
|
|
/** @var d3usermanager_execute $execute */
|
|
|
|
$execute = d3GetModCfgDIC()->get(d3usermanager_execute::class);
|
|
|
|
|
|
|
|
return $execute;
|
|
|
|
}
|
2021-03-15 15:17:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Manager $oManager
|
|
|
|
* @throws d3ActionRequirementAbstract
|
|
|
|
*/
|
|
|
|
protected function d3UserManagerCheckForConfigurationException(Manager $oManager): void
|
|
|
|
{
|
|
|
|
d3GetModCfgDIC()->set(d3usermanager_configurationcheck::class.'.args.usermanager', $oManager);
|
|
|
|
d3GetModCfgDIC()->setParameter(
|
|
|
|
d3usermanager_configurationcheck::class.'.args.checktypes',
|
|
|
|
$oManager->getValue('sManuallyExecMeetCondition') ?
|
|
|
|
d3usermanager_configurationcheck::REQUIREMENTS_AND_ACTIONS :
|
|
|
|
d3usermanager_configurationcheck::ACTIONS_ONLY
|
|
|
|
);
|
|
|
|
/** @var d3usermanager_configurationcheck $confCheck */
|
|
|
|
$confCheck = d3GetModCfgDIC()->get(d3usermanager_configurationcheck::class);
|
|
|
|
$confCheck->checkThrowingExceptions();
|
|
|
|
}
|
2020-10-02 11:59:22 +02:00
|
|
|
}
|