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

[BUGFIX] Fix regression on editor setup needed #380

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
6 changes: 5 additions & 1 deletion Classes/Event/Listener/GlossarySyncButtonProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion Classes/Hooks/ButtonBarHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion Classes/Override/Core11/DatabaseRecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 9 additions & 2 deletions Classes/Override/Core11/DeeplRecordListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 '';
}

Expand Down
7 changes: 6 additions & 1 deletion Classes/Override/Core12/DatabaseRecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 9 additions & 2 deletions Classes/Override/Core12/DeeplRecordListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 '';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down