diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php index 1718cb8..5c1bca4 100644 --- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php +++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php @@ -66,9 +66,6 @@ class PagesIndexer extends TcaIndexer { parent::prepareRecord($record); - // Override access from parent rootline - $record['search_access'] = $this->fetchAccess($record['uid'], (array)$record['search_access']); - $possibleTitleFields = ['nav_title', 'tx_tqseo_pagetitle_rel', 'title']; foreach ($possibleTitleFields as $searchTitleField) { if (isset($record[$searchTitleField]) && trim($record[$searchTitleField])) { @@ -140,41 +137,6 @@ class PagesIndexer extends TcaIndexer return $this->fetchSysFileReferenceUids($uid, 'pages', 'media'); } - protected function fetchAccess(int $uid, array $pageAccess): array - { - try { - $rootline = $this->objectManager->get(RootlineUtility::class, $uid)->get(); - } catch (\RuntimeException $e) { - $this->logger->notice( - sprintf('Could not fetch rootline for page %u, because: %s', $uid, $e->getMessage()), - [$pageAccess, $e] - ); - return $pageAccess; - } - - $access = [$pageAccess]; - $extended = false; - foreach ($rootline as $pageInRootLine) { - if ($pageInRootLine['extendToSubpages'] && (!empty($pageInRootLine['fe_group']))) { - $extended = true; - $access[] = GeneralUtility::intExplode( - ',', - $pageInRootLine['fe_group'], - true - ); - } - } - - // Return combined rootline extended access and return unique id's - $access = array_unique(array_merge(...$access)); - - // Remove public value if fe_group is extended to this page - if ($extended && ($key = array_search(0, $access, true)) !== false) { - unset($access[$key]); - } - return array_values($access); - } - protected function fetchSysFileReferenceUids(int $uid, string $tablename, string $fieldname): array { $imageRelationUids = []; diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index ab5c70c..8e5cde9 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -146,19 +146,6 @@ class TcaTableService implements TcaTableServiceInterface if (isset($record[$this->tca['ctrl']['label']]) && !isset($record['search_title'])) { $record['search_title'] = $record[$this->tca['ctrl']['label']]; } - - if (isset( - $this->tca['ctrl']['enablecolumns']['fe_group'], - $record[$this->tca['ctrl']['enablecolumns']['fe_group']] - )) { - $groups = GeneralUtility::intExplode( - ',', - $record[$this->tca['ctrl']['enablecolumns']['fe_group']], - true - ); - // Always fallback on public visibility when configured - $record['search_access'] = !empty($groups) ? $groups : [0]; - } } protected function getWhereClause(): Where diff --git a/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php b/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php deleted file mode 100644 index 42f9d2c..0000000 --- a/Classes/Domain/Search/Filter/FrontendUserAccessFilter.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; - -/** - * Filter: FrontendUserAccess - */ -class FrontendUserAccessFilter implements SearchFilterInterface -{ - public function add(array $query, array $config, $value): array - { - return $this->addAccessFilter($query, $value); - } - - /** - * Add simple boolean lookup for filtering on access groups - */ - protected function addAccessFilter(array $query, string $field): array - { - $query['query']['bool']['must'][] = [ - 'terms' => [$field => $this->getUserGroups()] - ]; - return $query; - } - - /** - * Get inherited user groups from logged in user or simulated user - */ - protected function getUserGroups(): array - { - $feUser = $this->getFrontendUserAuthentication(); - if ($feUser !== null) { - // If groups is not yet rendered, make sure the group data are fetched - if (!isset($feUser->groupData['uid'])) { - $feUser->fetchGroupData(); - } - - $values = $feUser->groupData['uid']; - if (!empty($values)) { - // Add public content with values - return array_merge([0], $values); - } - } - - // Fallback on public content - return [0]; - } - - protected function getFrontendUserAuthentication(): FrontendUserAuthentication - { - return $GLOBALS['TSFE']->fe_user ?? null; - } -} diff --git a/Classes/Domain/Search/Filter/InvalidSearchFilterException.php b/Classes/Domain/Search/Filter/InvalidSearchFilterException.php deleted file mode 100644 index 7199c58..0000000 --- a/Classes/Domain/Search/Filter/InvalidSearchFilterException.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -class InvalidSearchFilterException extends \InvalidArgumentException -{ -} diff --git a/Classes/Domain/Search/Filter/SearchFilterInterface.php b/Classes/Domain/Search/Filter/SearchFilterInterface.php deleted file mode 100644 index fa781d6..0000000 --- a/Classes/Domain/Search/Filter/SearchFilterInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -interface SearchFilterInterface -{ - /** - * @param array $query - * @param array $config - * @param mixed $value - * @return array Adjusted $query - */ - public function add(array $query, array $config, $value): array; -} diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php index 0c0969f..f34befc 100644 --- a/Classes/Domain/Search/QueryFactory.php +++ b/Classes/Domain/Search/QueryFactory.php @@ -25,8 +25,6 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\ConfigurationUtility; use Codappix\SearchCore\Configuration\InvalidArgumentException; use Codappix\SearchCore\Connection\SearchRequestInterface; -use Codappix\SearchCore\Domain\Search\Filter\InvalidSearchFilterException; -use Codappix\SearchCore\Domain\Search\Filter\SearchFilterInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; @@ -252,18 +250,6 @@ class QueryFactory return $query; } - if ($config['custom'] && $config['type'] === 'custom') { - $customFilter = $this->objectManager->get($config['custom']); - if (!($customFilter instanceof SearchFilterInterface)) { - throw new InvalidSearchFilterException( - 'Custom filter (' . $config['custom'] . ') not instance of SearchFilterInterface', - 1539876182018 - ); - } - - return $customFilter->add($query, $config, $value); - } - $filter = []; if (isset($config['fields'])) { foreach ($config['fields'] as $elasticField => $inputField) { diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index f3429ae..7ff8d29 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -36,19 +36,6 @@ plugin.tx_searchcore { # Default query fields (leave empty for all) query = } - - filter { - frontendUserAccess = search_access - } - - mapping { - filter { - frontendUserAccess { - type = custom - custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter - } - } - } } } } diff --git a/Documentation/source/changelog/20181028-user-access-indexed.rst b/Documentation/source/changelog/20181028-user-access-indexed.rst deleted file mode 100644 index 2456e1a..0000000 --- a/Documentation/source/changelog/20181028-user-access-indexed.rst +++ /dev/null @@ -1,14 +0,0 @@ -Feature "Added frontend user authentication access" -=================================================== - -Indexation added based on page access via ``fe_group`` and inherited -from ```extendToSubpages```. - -The searching is added via typoscript using the UserFunc filter:: - - frontendUserAccess { - type = custom - custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter - } - -To bypass this filter simply unset default filter in searching.filter diff --git a/Documentation/source/changelog/20181030-custom-class-filter.rst b/Documentation/source/changelog/20181030-custom-class-filter.rst deleted file mode 100644 index 07a305d..0000000 --- a/Documentation/source/changelog/20181030-custom-class-filter.rst +++ /dev/null @@ -1,29 +0,0 @@ -Feature "Manipulate search filter" -================================== - -You can manipulate the filter via a custom class through the ``custom`` type typoscript -mapping.:: - - plugin.tx_searchcore.settings.searching { - mapping { - filter { - frontendUserAccess { - type = custom - custom = Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter - } - } - } - } - -If you want to force this filter on searching make sure to define them as default filters like::: - - plugin.tx_searchcore.settings.searching { - filter { - frontendUserAccess = search_access - } - } - -Example -------- -See ``Codappix\SearchCore\Domain\Search\Filter\FrontendUserAccessFilter`` as example. -