Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add check provider #49

Open
wants to merge 2 commits into
base: 7-8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Classes/Provider/BackendUserProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
namespace T3Monitor\T3monitoringClient\Provider;

/*
* This file is part of the t3monitoring_client extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class BackendUserProvider implements DataProviderInterface
{

public function get(array $data)
{
$backendUsers = GeneralUtility::_GP('backendUser');
$data['backendUser'] = [];
if (isset($backendUsers) && is_array($backendUsers) && count($backendUsers) > 0) {
$table = 'be_users';
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);

$users = [];
foreach ($backendUsers as $backendUser) {
$users[] = $queryBuilder->createNamedParameter($backendUser);
}

$rows = $queryBuilder
->select('username')
->from($table)
->where(
$queryBuilder->expr()->in('username', $users)
)
->execute()
->fetchAll();

foreach ($rows as $backendUser) {
$data['backendUser'][] = $backendUser['username'];
}
};
return $data;
}
}
60 changes: 60 additions & 0 deletions Classes/Provider/ConfigurationProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace T3Monitor\T3monitoringClient\Provider;

use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ConfigurationProvider implements DataProviderInterface
{
/**
* Blind configuration options which should not be visible
*
* Source: \TYPO3\CMS\Lowlevel\View\ConfigurationView
*
* @var array
*/
protected static $blindedConfigurationOptions = [
'TYPO3_CONF_VARS' => [
'DB' => [
'database' => '******',
'host' => '******',
'password' => '******',
'port' => '******',
'socket' => '******',
'username' => '******',
'Connections' => [
'Default' => [
'dbname' => '******',
'host' => '******',
'password' => '******',
'port' => '******',
'user' => '******',
'unix_socket' => '******',
],
],
],
'SYS' => [
'encryptionKey' => '******'
]
]
];

public function get(array $data)
{
$configuration = $GLOBALS['TYPO3_CONF_VARS'];
ArrayUtility::mergeRecursiveWithOverrule(
$configuration,
ArrayUtility::intersectRecursive(self::$blindedConfigurationOptions['TYPO3_CONF_VARS'], $configuration)
);

$configurationValues = GeneralUtility::_GP('configurationValue');
foreach ($configurationValues as $path) {
if (ArrayUtility::isValidPath($configuration, $path)) {
$data['configuration'][$path] = ArrayUtility::getValueByPath($configuration, $path);
}
}

return $data;
}
}
2 changes: 2 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

if ($version >= 8) {
$GLOBALS['TYPO3_CONF_VARS']['EXT']['t3monitoring_client']['provider'][] = 'T3Monitor\\T3monitoringClient\\Provider\\ServerInformation8xProvider';
$GLOBALS['TYPO3_CONF_VARS']['EXT']['t3monitoring_client']['provider'][] = 'T3Monitor\\T3monitoringClient\\Provider\\ConfigurationProvider';
$GLOBALS['TYPO3_CONF_VARS']['EXT']['t3monitoring_client']['provider'][] = 'T3Monitor\\T3monitoringClient\\Provider\\BackendUserProvider';
} else {
$GLOBALS['TYPO3_CONF_VARS']['EXT']['t3monitoring_client']['provider'][] = 'T3Monitor\\T3monitoringClient\\Provider\\ServerInformationProvider';
}
Expand Down