diff --git a/Classes/Event/Listener/GlossarySyncButtonProvider.php b/Classes/Event/Listener/GlossarySyncButtonProvider.php index 490aaea7..c96de260 100644 --- a/Classes/Event/Listener/GlossarySyncButtonProvider.php +++ b/Classes/Event/Listener/GlossarySyncButtonProvider.php @@ -11,6 +11,7 @@ use TYPO3\CMS\Backend\Template\Components\ModifyButtonBarEvent; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Configuration\Features; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; @@ -59,7 +60,10 @@ public function __invoke(ModifyButtonBarEvent $event): void return; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC) + ) { return; } diff --git a/Classes/Hooks/ButtonBarHook.php b/Classes/Hooks/ButtonBarHook.php index f65b71f3..7adbaa3d 100644 --- a/Classes/Hooks/ButtonBarHook.php +++ b/Classes/Hooks/ButtonBarHook.php @@ -9,6 +9,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Configuration\Features; use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; @@ -49,7 +50,10 @@ public function getButtons(array $params, ButtonBar $buttonBar): array return $buttons; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC) + ) { return $buttons; } diff --git a/Classes/Override/Core11/DatabaseRecordList.php b/Classes/Override/Core11/DatabaseRecordList.php index e5034a8b..afde586d 100644 --- a/Classes/Override/Core11/DatabaseRecordList.php +++ b/Classes/Override/Core11/DatabaseRecordList.php @@ -5,6 +5,8 @@ namespace WebVision\WvDeepltranslate\Override\Core11; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; use WebVision\WvDeepltranslate\Access\AllowedTranslateAccess; use WebVision\WvDeepltranslate\Utility\DeeplBackendUtility; @@ -34,7 +36,10 @@ public function makeLocalizationPanel($table, $row, array $translations): string return $out; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE) + ) { return $out; } diff --git a/Classes/Override/Core11/DeeplRecordListController.php b/Classes/Override/Core11/DeeplRecordListController.php index c3917d49..1b6a158a 100644 --- a/Classes/Override/Core11/DeeplRecordListController.php +++ b/Classes/Override/Core11/DeeplRecordListController.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Exception; use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; +use TYPO3\CMS\Core\Configuration\Features; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; @@ -42,7 +43,10 @@ protected function languageSelector(string $requestUri, $_forwardCore12CombatAnd return $originalOutput; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE) + ) { return $originalOutput; } @@ -81,7 +85,10 @@ private function buildGlossaryTranslationOptionDropdown(string $requestUri): str return ''; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC) + ) { return ''; } diff --git a/Classes/Override/Core12/DatabaseRecordList.php b/Classes/Override/Core12/DatabaseRecordList.php index bf83352c..a8e5b125 100644 --- a/Classes/Override/Core12/DatabaseRecordList.php +++ b/Classes/Override/Core12/DatabaseRecordList.php @@ -4,6 +4,8 @@ namespace WebVision\WvDeepltranslate\Override\Core12; +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; use WebVision\WvDeepltranslate\Access\AllowedTranslateAccess; use WebVision\WvDeepltranslate\Utility\DeeplBackendUtility; @@ -33,7 +35,10 @@ public function makeLocalizationPanel($table, $row, array $translations): string return $out; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE) + ) { return $out; } diff --git a/Classes/Override/Core12/DeeplRecordListController.php b/Classes/Override/Core12/DeeplRecordListController.php index 91e50628..e6162154 100644 --- a/Classes/Override/Core12/DeeplRecordListController.php +++ b/Classes/Override/Core12/DeeplRecordListController.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\Exception; use TYPO3\CMS\Backend\Controller\RecordListController; use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; +use TYPO3\CMS\Core\Configuration\Features; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; @@ -46,7 +47,10 @@ protected function languageSelector(array $siteLanguages, string $requestUri): s return $originalOutput; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE) + ) { return $originalOutput; } @@ -84,7 +88,10 @@ private function buildGlossaryTranslationOptionDropdown(array $siteLanguages, st return ''; } - if (!$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC)) { + if ( + GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + && !$this->getBackendUserAuthentication()->check('custom_options', AllowedGlossarySyncAccess::ALLOWED_GLOSSARY_SYNC) + ) { return ''; } diff --git a/Classes/ViewHelpers/Be/Access/DeeplTranslateAllowedViewHelper.php b/Classes/ViewHelpers/Be/Access/DeeplTranslateAllowedViewHelper.php index b5daf3da..db430bce 100644 --- a/Classes/ViewHelpers/Be/Access/DeeplTranslateAllowedViewHelper.php +++ b/Classes/ViewHelpers/Be/Access/DeeplTranslateAllowedViewHelper.php @@ -5,6 +5,8 @@ namespace WebVision\WvDeepltranslate\ViewHelpers\Be\Access; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Configuration\Features; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; use WebVision\WvDeepltranslate\Access\AllowedTranslateAccess; @@ -18,7 +20,10 @@ public function initializeArguments(): void public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool { - if (self::getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE)) { + if ( + !GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('deeplTranslationUserConfigured') + || self::getBackendUserAuthentication()->check('custom_options', AllowedTranslateAccess::ALLOWED_TRANSLATE_OPTION_VALUE) + ) { return true; } diff --git a/ext_localconf.php b/ext_localconf.php index 379cc2d5..caf5c0d1 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -95,6 +95,8 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['wvdeepltranslate']['backend'] ??= \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['deeplTranslationUserConfigured'] ??= false; + $accessRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\WebVision\WvDeepltranslate\Access\AccessRegistry::class); $accessRegistry->addAccess((new \WebVision\WvDeepltranslate\Access\AllowedTranslateAccess())); $accessRegistry->addAccess((new \WebVision\WvDeepltranslate\Access\AllowedGlossarySyncAccess()));