mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-23 14:16:11 +01:00
[BUGFIX] Inherit access groups from parent pages when extended to subpages
This commit is contained in:
parent
3f5273f0fe
commit
519bc7e5b4
2 changed files with 48 additions and 1 deletions
|
@ -25,6 +25,8 @@ use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
||||||
use Codappix\SearchCore\Connection\ConnectionInterface;
|
use Codappix\SearchCore\Connection\ConnectionInterface;
|
||||||
use Codappix\SearchCore\Domain\Index\TcaIndexer;
|
use Codappix\SearchCore\Domain\Index\TcaIndexer;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
use TYPO3\CMS\Core\Utility\RootlineUtility;
|
||||||
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific indexer for Pages, will basically add content of page.
|
* Specific indexer for Pages, will basically add content of page.
|
||||||
|
@ -65,6 +67,9 @@ class PagesIndexer extends TcaIndexer
|
||||||
{
|
{
|
||||||
parent::prepareRecord($record);
|
parent::prepareRecord($record);
|
||||||
|
|
||||||
|
// Override access from parent rootline
|
||||||
|
$record['search_access'] = $this->fetchAccess($record['uid'], $record['search_access']);
|
||||||
|
|
||||||
$possibleTitleFields = ['nav_title', 'tx_tqseo_pagetitle_rel', 'title'];
|
$possibleTitleFields = ['nav_title', 'tx_tqseo_pagetitle_rel', 'title'];
|
||||||
foreach ($possibleTitleFields as $searchTitleField) {
|
foreach ($possibleTitleFields as $searchTitleField) {
|
||||||
if (isset($record[$searchTitleField]) && trim($record[$searchTitleField])) {
|
if (isset($record[$searchTitleField]) && trim($record[$searchTitleField])) {
|
||||||
|
@ -148,6 +153,47 @@ class PagesIndexer extends TcaIndexer
|
||||||
return $this->fetchSysFileReferenceUids($uid, 'pages', 'media');
|
return $this->fetchSysFileReferenceUids($uid, 'pages', 'media');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $uid
|
||||||
|
* @param array $pageAccess
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function fetchAccess(int $uid, array $pageAccess): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||||
|
$rootline = $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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $uid
|
* @param integer $uid
|
||||||
* @param string $tablename
|
* @param string $tablename
|
||||||
|
|
|
@ -171,7 +171,8 @@ class TcaTableService implements TcaTableServiceInterface
|
||||||
if (isset($record[$this->tca['ctrl']['label']]) && !isset($record['search_title'])) {
|
if (isset($record[$this->tca['ctrl']['label']]) && !isset($record['search_title'])) {
|
||||||
$record['search_title'] = $record[$this->tca['ctrl']['label']];
|
$record['search_title'] = $record[$this->tca['ctrl']['label']];
|
||||||
}
|
}
|
||||||
if (isset($this->tca['ctrl']['enablecolumns']['fe_group']) && isset($record[$this->tca['ctrl']['enablecolumns']['fe_group']])) {
|
|
||||||
|
if (isset($this->tca['ctrl']['enablecolumns']['fe_group'], $record[$this->tca['ctrl']['enablecolumns']['fe_group']])) {
|
||||||
$groups = GeneralUtility::intExplode(
|
$groups = GeneralUtility::intExplode(
|
||||||
',',
|
',',
|
||||||
$record[$this->tca['ctrl']['enablecolumns']['fe_group']],
|
$record[$this->tca['ctrl']['enablecolumns']['fe_group']],
|
||||||
|
|
Loading…
Reference in a new issue