[BUGFIX] Fix links of shortcuts to restricted pages in menus 26/33726/2
authorHelmut Hummel <helmut-hummel@typo3.org>
Fri, 24 Oct 2014 01:39:00 +0000 (03:39 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 2 Nov 2014 19:48:56 +0000 (20:48 +0100)
Fix missing links in menus when shortcuts point to access restricted
pages or shortcuts themselves are restricted.

This fixes TypoScript menu option "showAccessRestrictedPages"

Resolves: #60258
Releases: master, 6.2
Change-Id: I25739e776bae99e8b8b9787be515c04a60c2706d
Reviewed-on: http://review.typo3.org/33726
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 76f417e..7f5ec9e 100644 (file)
@@ -1313,17 +1313,21 @@ class AbstractMenuContentObject {
                        $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array('parameter' => $this->menuArr[$key]['url']));
                        $LD['target'] = '';
                }
+
                // Override url if current page is a shortcut
+               $shortcut = NULL;
                if ($this->menuArr[$key]['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT && $this->menuArr[$key]['shortcut_mode'] != \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
 
                        $menuItem = $this->determineOriginalShortcutPage($this->menuArr[$key]);
 
-                       $shortcut = NULL;
                        try {
                                $shortcut = $GLOBALS['TSFE']->getPageShortcut(
                                        $menuItem['shortcut'],
                                        $menuItem['shortcut_mode'],
-                                       $menuItem['uid']
+                                       $menuItem['uid'],
+                                       20,
+                                       array(),
+                                       TRUE
                                );
                        } catch (\Exception $ex) {
 
@@ -1335,10 +1339,17 @@ class AbstractMenuContentObject {
                        $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array(
                                'parameter' => $shortcut['uid'],
                                'additionalParams' => $this->mconf['addParams'] . $MP_params . $this->I['val']['additionalParams'] . $menuItem['_ADD_GETVARS'],
+                               'linkAccessRestrictedPages' => $this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE'
                        ));
                }
+               if ($shortcut) {
+                       $pageData = $shortcut;
+                       $pageData['_SHORTCUT_PAGE_UID'] = $this->menuArr[$key]['uid'];
+               } else {
+                       $pageData = $this->menuArr[$key];
+               }
                // Manipulation in case of access restricted pages:
-               $this->changeLinksForAccessRestrictedPages($LD, $this->menuArr[$key], $mainTarget, $typeOverride);
+               $this->changeLinksForAccessRestrictedPages($LD, $pageData, $mainTarget, $typeOverride);
                // Overriding URL / Target if set to do so:
                if ($this->menuArr[$key]['_OVERRIDE_HREF']) {
                        $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF'];
@@ -1442,7 +1453,7 @@ class AbstractMenuContentObject {
                                ),
                                array(
                                        rawurlencode($LD['totalURL']),
-                                       $page['uid']
+                                       isset($page['_SHORTCUT_PAGE_UID']) ? $page['_SHORTCUT_PAGE_UID'] : $page['uid']
                                ),
                                $this->mconf['showAccessRestrictedPages.']['addParams']
                        );
@@ -1814,6 +1825,7 @@ class AbstractMenuContentObject {
                if ($page['sectionIndex_uid']) {
                        $conf['section'] = $page['sectionIndex_uid'];
                }
+               $conf['linkAccessRestrictedPages'] = $this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE';
                $this->parent_cObj->typoLink('|', $conf);
                $LD = $this->parent_cObj->lastTypoLinkLD;
                $LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
index 58b39b0..86beede 100644 (file)
@@ -1670,6 +1670,7 @@ class TypoScriptFrontendController {
         * @param integer $thisUid The current page UID of the page which is a shortcut
         * @param integer $itera Safety feature which makes sure that the function is calling itself recursively max 20 times (since this function can find shortcuts to other shortcuts to other shortcuts...)
         * @param array $pageLog An array filled with previous page uids tested by the function - new page uids are evaluated against this to avoid going in circles.
+        * @param bool $disableGroupCheck If true, the group check is disabled when fetching the target page (needed e.g. for menu generation)
         * @throws \RuntimeException
         * @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
         * @return mixed Returns the page record of the page that the shortcut pointed to.
@@ -1677,7 +1678,7 @@ class TypoScriptFrontendController {
         * @see getPageAndRootline()
         * @todo Define visibility
         */
-       public function getPageShortcut($SC, $mode, $thisUid, $itera = 20, $pageLog = array()) {
+       public function getPageShortcut($SC, $mode, $thisUid, $itera = 20, $pageLog = array(), $disableGroupCheck = FALSE) {
                $idArray = GeneralUtility::intExplode(',', $SC);
                // Find $page record depending on shortcut mode:
                switch ($mode) {
@@ -1704,15 +1705,15 @@ class TypoScriptFrontendController {
                                }
                                break;
                        case \TYPO3\CMS\Frontend\Page\PageRepository::SHORTCUT_MODE_PARENT_PAGE:
-                               $parent = $this->sys_page->getPage($thisUid);
-                               $page = $this->sys_page->getPage($parent['pid']);
+                               $parent = $this->sys_page->getPage($thisUid, $disableGroupCheck);
+                               $page = $this->sys_page->getPage($parent['pid'], $disableGroupCheck);
                                if (count($page) == 0) {
                                        $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to its parent page. ' . 'However, the parent page is not accessible.';
                                        throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648358);
                                }
                                break;
                        default:
-                               $page = $this->sys_page->getPage($idArray[0]);
+                               $page = $this->sys_page->getPage($idArray[0], $disableGroupCheck);
                                if (count($page) == 0) {
                                        $message = 'This page (ID ' . $thisUid . ') is of type "Shortcut" and configured to redirect to a page, which is not accessible (ID ' . $idArray[0] . ').';
                                        throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException($message, 1301648404);
@@ -1722,7 +1723,7 @@ class TypoScriptFrontendController {
                if ($page['doktype'] == \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
                        if (!in_array($page['uid'], $pageLog) && $itera > 0) {
                                $pageLog[] = $page['uid'];
-                               $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $itera - 1, $pageLog);
+                               $page = $this->getPageShortcut($page['shortcut'], $page['shortcut_mode'], $page['uid'], $itera - 1, $pageLog, $disableGroupCheck);
                        } else {
                                $pageLog[] = $page['uid'];
                                $message = 'Page shortcuts were looping in uids ' . implode(',', $pageLog) . '...!';