[BUGFIX] Remove non accessible pages from browse menu 33/32333/2
authorKay Strobach <typo3@kay-strobach.de>
Wed, 14 May 2014 07:26:13 +0000 (09:26 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Sat, 23 Aug 2014 14:54:57 +0000 (16:54 +0200)
This patch enables the browse menu to skip inaccessible items
for prev and next links.

It makes use of the filterMenuPages method, which is already
applied to any kind of menu. Since it has not been applied
to the sections of the browse menu type, which are actually
menus themselves, inaccessible pages made browsing unusable.

This applies to missing translations as well.

Change-Id: I8779731139785dea72b078567912c96e3ad5c7ca
Resolves: #58792
Releases: 6.3, 6.2
Reviewed-on: http://review.typo3.org/32333
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php

index 7b58247..ce686e5 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Generating navigation / menus from TypoScript
@@ -734,7 +735,7 @@ class AbstractMenuContentObject {
                                                                $recArr['index'] = $this->sys_page->getPage($recArr['up']['pid']);
                                                        }
                                                        // prev / next is found
-                                                       $prevnext_menu = $this->sys_page->getMenu($value_rec['pid'], '*', $altSortField);
+                                                       $prevnext_menu = $this->removeInaccessiblePages($this->sys_page->getMenu($value_rec['pid'], '*', $altSortField));
                                                        $lastKey = 0;
                                                        $nextActive = 0;
                                                        foreach ($prevnext_menu as $k_b => $v_b) {
@@ -757,12 +758,12 @@ class AbstractMenuContentObject {
                                                        // prevsection / nextsection is found
                                                        // You can only do this, if there is a valid page two levels up!
                                                        if (is_array($recArr['index'])) {
-                                                               $prevnextsection_menu = $this->sys_page->getMenu($recArr['index']['uid'], '*', $altSortField);
+                                                               $prevnextsection_menu = $this->removeInaccessiblePages($this->sys_page->getMenu($recArr['index']['uid'], '*', $altSortField));
                                                                $lastKey = 0;
                                                                $nextActive = 0;
                                                                foreach ($prevnextsection_menu as $k_b => $v_b) {
                                                                        if ($nextActive) {
-                                                                               $sectionRec_temp = $this->sys_page->getMenu($v_b['uid'], '*', $altSortField);
+                                                                               $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($v_b['uid'], '*', $altSortField));
                                                                                if (count($sectionRec_temp)) {
                                                                                        reset($sectionRec_temp);
                                                                                        $recArr['nextsection'] = pos($sectionRec_temp);
@@ -773,7 +774,7 @@ class AbstractMenuContentObject {
                                                                        }
                                                                        if ($v_b['uid'] == $value_rec['pid']) {
                                                                                if ($lastKey) {
-                                                                                       $sectionRec_temp = $this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'], '*', $altSortField);
+                                                                                       $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'], '*', $altSortField));
                                                                                        if (count($sectionRec_temp)) {
                                                                                                reset($sectionRec_temp);
                                                                                                $recArr['prevsection'] = pos($sectionRec_temp);
@@ -907,6 +908,18 @@ class AbstractMenuContentObject {
        }
 
        /**
+        * Gets an array of page rows and removes all, which are not accessible
+        *
+        * @param array $pages
+        * @return array
+        */
+       protected function removeInaccessiblePages(array $pages) {
+               return array_filter($pages, function($page) {
+                       return $this->filterMenuPages($page, $this->getBannedUids(), $page['doktype'] === PageRepository::DOKTYPE_SPACER);
+               });
+       }
+
+       /**
         * Analyzes the parameters to find if the link needs a cHash parameter.
         *
         * @param string $queryString