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

[FEATURE] Add support for uid #13

Merged
merged 1 commit into from
Apr 4, 2022
Merged
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
19 changes: 18 additions & 1 deletion Classes/Domain/Repository/PageTreeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class PageTreeRepository extends \TYPO3\CMS\Backend\Tree\Repository\PageTreeRepo
'tt_content:CType',
'tt_content:list_type',
];
// allowed fields, regardless of table
protected const ALLOWED_FIELDS = [
'uid',
];

public function fetchFilteredTree(string $searchFilter, array $allowedMountPointPageIds, string $additionalWhereClause): array
{
Expand Down Expand Up @@ -136,9 +140,21 @@ protected function validate()
if (!$backendUser->isAdmin() && !$backendUser->check('tables_select', $this->filterTable)) {
self::$filterErrorneous = true;
}
$connection = $connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($this->filterTable);
foreach($this->filterConstraints as $constraint) {
if (!isset($GLOBALS['TCA'][$this->filterTable]['columns'][$constraint['field']])) {
self::$filterErrorneous = true;
// only if admin or field in ALLOWED_FIELDS: field can also be used if not in TCA, but exists in table
if (($backendUser->isAdmin() || in_array($constraint['field'], self::ALLOWED_FIELDS))
&& in_array($constraint['field'], array_keys($connection->getSchemaManager()->listTableColumns($this->filterTable)))
) {
// all good for this constraint, keep going
continue;
} else {
self::$filterErrorneous = true;
// filter error - no need to check further
return;
}
}
$tableField = $this->filterTable . ':' . $constraint['field'];
if (
Expand All @@ -147,6 +163,7 @@ protected function validate()
!$backendUser->check('non_exclude_fields', $tableField)
) {
self::$filterErrorneous = true;
return;
}
}
}
Expand Down