Skip to content

Commit e110d97

Browse files
[BACKPORT][BUGFIX] respect "includeHiddenContent" for plugin validation
Relates: #680 (cherry picked from commit 225416f)
1 parent bc55365 commit e110d97

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Classes/Domain/Repository/PluginRepository.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
use Exception;
88
use In2code\Femanager\Domain\Service\PluginService;
99
use In2code\Femanager\Utility\ObjectUtility;
10+
use TYPO3\CMS\Core\Context\Context;
1011
use PDO;
12+
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
13+
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
14+
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
1115
use TYPO3\CMS\Core\Service\FlexFormService;
1216
use TYPO3\CMS\Core\Utility\GeneralUtility;
1317

@@ -20,12 +24,16 @@ class PluginRepository
2024

2125
protected FlexFormService $flexFormService;
2226

27+
protected Context $context;
28+
2329
/**
30+
* @param Context|null $context
2431
* @param FlexFormService|null $flexFormService
2532
*/
26-
public function __construct(FlexFormService $flexFormService = null)
33+
public function __construct(?Context $context = null, ?FlexFormService $flexFormService = null)
2734
{
2835
$this->flexFormService = $flexFormService ?? GeneralUtility::makeInstance(FlexFormService::class);
36+
$this->context = $context ?? GeneralUtility::makeInstance(Context::class);
2937
}
3038

3139
/**
@@ -39,7 +47,7 @@ public function isPluginWithViewOnGivenPage(int $pageIdentifier, string $pluginN
3947
if (in_array($pluginName, $allowedPlugins)) {
4048
$queryBuilder = ObjectUtility::getQueryBuilder(self::TABLE_NAME);
4149
$cType = str_replace('tx_', '', $pluginName);
42-
$pluginOnPageQuery = $queryBuilder
50+
$statement = $queryBuilder
4351
->select('uid')
4452
->from(self::TABLE_NAME)
4553
->where(
@@ -51,8 +59,18 @@ public function isPluginWithViewOnGivenPage(int $pageIdentifier, string $pluginN
5159
'CType',
5260
$queryBuilder->createNamedParameter($cType, PDO::PARAM_STR)
5361
)
54-
)
55-
->executeQuery();
62+
);
63+
64+
if ($this->context->getPropertyFromAspect('visibility', 'includeHiddenContent')) {
65+
$statement
66+
->getRestrictions()
67+
->removeByType(HiddenRestriction::class)
68+
->removeByType(StartTimeRestriction::class)
69+
->removeByType(EndTimeRestriction::class);
70+
}
71+
72+
$pluginOnPageQuery = $statement->executeQuery();
73+
5674
return count($pluginOnPageQuery->fetchAllAssociative()) > 0;
5775
}
5876

0 commit comments

Comments
 (0)