diff --git a/Classes/Domain/Model/Dto/ResolverData.php b/Classes/Domain/Model/Dto/ResolverData.php index 54ed3e0..961af74 100644 --- a/Classes/Domain/Model/Dto/ResolverData.php +++ b/Classes/Domain/Model/Dto/ResolverData.php @@ -8,6 +8,8 @@ * LICENSE.txt file that was distributed with this source code. */ +use T3Monitor\T3monitoring\Domain\Model\Rule; + class ResolverData { /** @@ -25,6 +27,11 @@ class ResolverData */ protected $responseHeaders; + /** + * @var Rule + */ + protected $rule; + public function __construct(array $client, array $response, array $responseHeaders) { $this->client = $client; @@ -79,4 +86,21 @@ public function setResponseHeaders(array $responseHeaders) { $this->responseHeaders = $responseHeaders; } + + /** + * @return Rule + */ + public function getRule() + { + return $this->rule; + } + + /** + * @param Rule $rule + */ + public function setRule(Rule $rule) + { + $this->rule = $rule; + } + } \ No newline at end of file diff --git a/Classes/Resolver/BackendUserResolver.php b/Classes/Resolver/BackendUserResolver.php new file mode 100644 index 0000000..1098a72 --- /dev/null +++ b/Classes/Resolver/BackendUserResolver.php @@ -0,0 +1,43 @@ +valueForComparison = $this->resolverData->getResponse()['backendUser']; + } + + public function getProviderArguments() + { + return GeneralUtility::trimExplode(PHP_EOL, $this->argument, true); + } + + protected function isActiveOperator() + { + if (!isset($this->resolverData->getResponse()['backendUser'])) { + return; + } + + $unwantedActiveUsers = array_intersect($this->getProviderArguments(), + $this->resolverData->getResponse()['backendUser']); + + if (count($unwantedActiveUsers) > 0) { + $this->addRuleData($unwantedActiveUsers); + } + return $unwantedActiveUsers !== 0; + } + + protected function addRuleData($backendUsers) + { + $update = $this->resolverData->getResponse(); + $messageCategory = $this->resolverData->getRule()->getMessageCategory(); + $update['extra'][$messageCategory][$this->resolverData->getRule()->getTitle()] = implode(',', + $backendUsers); + $this->resolverData->setResponse($update); + } +} \ No newline at end of file diff --git a/Classes/Service/CheckResultService.php b/Classes/Service/CheckResultService.php index 464815e..eaa3d4e 100644 --- a/Classes/Service/CheckResultService.php +++ b/Classes/Service/CheckResultService.php @@ -62,7 +62,11 @@ public function getProviderArguments() foreach ($checks as $check) { $providerArguments = $this->getResolver($check)->getProviderArguments(); if ($providerArguments) { - $allProviderArguments[$check->getType()][] = $providerArguments; + if (is_array($providerArguments)) { + $allProviderArguments[$check->getType()] = $providerArguments; + } else { + $allProviderArguments[$check->getType()][] = $providerArguments; + } } } @@ -82,6 +86,7 @@ public function createCheckResult(ResolverData $resolverData) $checkResult->setClient($resolverData->getClient()['uid']); foreach ($this->rules as $rule) { + $this->resolverData->setRule($rule); $checkFailureCriterias = true; foreach ($rule->getExecutionCriteria() as $executionCriteria) { $checkFailureCriterias = $this->runCheck($executionCriteria); diff --git a/Classes/Service/Import/ClientImport.php b/Classes/Service/Import/ClientImport.php index cb0acb5..77d55b7 100644 --- a/Classes/Service/Import/ClientImport.php +++ b/Classes/Service/Import/ClientImport.php @@ -137,8 +137,10 @@ protected function importSingleClient(array $row) 'error_count' => 0 ]; - $checkResultCreationDemand = new ResolverData($row, $json, $responseHeaders); - $checkResult = $this->checkResultService->createCheckResult($checkResultCreationDemand); + $resolverData = new ResolverData($row, $json, $responseHeaders); + $checkResult = $this->checkResultService->createCheckResult($resolverData); + $json = $resolverData->getResponse(); + $update['earlier_check_result'] = $row['check_result']; $update['check_result'] = $checkResult->getUid(); diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_check.php b/Configuration/TCA/tx_t3monitoring_domain_model_check.php index 4931ed2..e4e819c 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_check.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_check.php @@ -100,6 +100,24 @@ ] ] ], + 'backendUser' => [ + 'showitem' => 'hidden, title, type, argument, operator', + 'columnsOverrides' => [ + 'argument' => [ + 'label' => 'List of backend users separated by newline', + 'config' => [ + 'type' => 'text' + ] + ], + 'operator' => [ + 'config' => [ + 'items' => [ + ['is active', 'isActive'], + ] + ] + ], + ] + ], ], 'columns' => [ 'hidden' => [ diff --git a/ext_localconf.php b/ext_localconf.php index 95451ff..8273658 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -12,6 +12,7 @@ function ($extKey) { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][$extKey] = \T3Monitor\T3monitoring\Hooks\DataHandlerHook::class; + $GLOBALS['TYPO3_CONF_VARS']['EXT'][$extKey]['resolver']['backendUser'] = \T3Monitor\T3monitoring\Resolver\BackendUserResolver::class; $GLOBALS['TYPO3_CONF_VARS']['EXT'][$extKey]['resolver']['configurationValue'] = \T3Monitor\T3monitoring\Resolver\ConfigurationResolver::class; $GLOBALS['TYPO3_CONF_VARS']['EXT'][$extKey]['resolver']['header'] = \T3Monitor\T3monitoring\Resolver\HeaderResolver::class; $GLOBALS['TYPO3_CONF_VARS']['EXT'][$extKey]['resolver']['extensionState'] = \T3Monitor\T3monitoring\Resolver\ExtensionStateResolver::class; diff --git a/ext_tables.sql b/ext_tables.sql index c8c528b..b5ff28e 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -206,7 +206,7 @@ CREATE TABLE tx_t3monitoring_domain_model_check ( title varchar(255) DEFAULT '' NOT NULL, type varchar(255) DEFAULT '' NOT NULL, - argument varchar(255) DEFAULT '' NOT NULL, + argument text DEFAULT '' NOT NULL, operator varchar(255) DEFAULT '' NOT NULL, value varchar(255) DEFAULT '' NOT NULL,