Project

General

Profile

Actions

Bug #25140

closed

RETURN_URL in menus is not created correctly

Added by Michael Hügelschäffer about 13 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-02-23
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

We actually have two sites where access restricted pages have to appear in menus. The menus have the options
showAccessRestrictedPages = loginPageId
showAccessRestrictedPages.addParams = &redirect_url=###RETURN_URL###
set.
In one case ###RETURN_URL### is replaced with the complete url, including all parameters. That results in an url like "/path/to/login-page/?redirect_url=/path/to/login-page/?redirect_url=/path/to/restriced-page/".
In the second website ###RETURN_URL### is replaced just with a blank string.

The method changeLinksForAccessRestrictedPages() in class tslib_menu replaces ###RETURN_URL### with $LD['totalURL']. $LD['totalURL'] is filled with $this->parent_cObj->lastTypoLinkUrl, which likely causes the problem.
Is there a certain reason to store the url in this way?
Or do you know of any misconfigration that may cause our problems? I did not check this behavious on a "clean" site yet.

IMHO is would make sense to create the url to restricted pages again with $this->parent_cObj->typoLink_Url() and before that temporarily set typolinkLinkAccessRestrictedPages to 'NONE' to get the link as if the page was not protected.

(issue imported from #M17718)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #22203: MENU.showAccessRestrictedPages.addParams generates wrong URLsClosed2010-02-26

Actions
Actions #1

Updated by Olivier Dobberkau over 11 years ago

  • Target version deleted (0)

Are you sure that your typoscript is OK?

Reading:

http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.1.0/view/10/1/

Example:

showAccessRestrictedPages = 22
showAccessRestrictedPages.addParams = &return_url=###RETURN_URL###&pageId=###PAGE_ID###
Actions #2

Updated by Michael Hügelschäffer over 11 years ago

Yes, TypoScript is OK. Even if it was not, the RETURN_URL-marker is still not replaced correctly.

Actions #3

Updated by Alexander Grein over 11 years ago

I can confirm this bug. I already spend several hours of debugging and i thing i found the problem:
Replacement is not working, because the menuTypoLink function in class.tslib_menu.php do not get a result from the typolink call on pages with restrictions.
Event not the lastTypoLinkUrl brings any result back.
My solution is to set the typolink configuration "linkAccessRestrictedPages", before generating the link.
To prevent double adding additional parameter, if the config.typolinkLinkAccessRestrictedPages is also enabled, some more thinks must be observed.

Here my suggestion how to fix (a patch will follow soon):

Line 1152:

            // Creating link:
        if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key)))    {
            $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
            $addParams = $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'];
            // in2code: bugfix for link generation of restricted pages
            $showAccessRestrictedPages = $this->mconf['showAccessRestrictedPages']
                    && $this->mconf['showAccessRestrictedPages']!=='NONE'
                    && !$GLOBALS['TSFE']->checkPageGroupAccess($thePage);
            if ($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']
                    && $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] !== 'NONE'
                    && !$GLOBALS['TSFE']->checkPageGroupAccess($thePage)) {
                // temporary deactivate typolinkLinkAccessRestrictedPages to disable double ###RETURN_URL### and ###PAGE_ID### replacement
                $tempTypolinkLinkAccessRestrictedPages = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'];
                unset($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']);
            }
            $LD = $this->menuTypoLink($thePage,$mainTarget,'','',$overrideArray, $addParams, $typeOverride, $showAccessRestrictedPages);
            $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] = $tempTypolinkLinkAccessRestrictedPages;
        } else {
            $addParams = $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'];
            // in2code: bugfix for link generation of restricted pages
            $showAccessRestrictedPages = $this->mconf['showAccessRestrictedPages']
                    && $this->mconf['showAccessRestrictedPages']!=='NONE'
                    && !$GLOBALS['TSFE']->checkPageGroupAccess($this->menuArr[$key]);
            if ($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']
                    && $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] !== 'NONE'
                    && !$GLOBALS['TSFE']->checkPageGroupAccess($this->menuArr[$key])) {
                // temporary deactivate typolinkLinkAccessRestrictedPages to disable double ###RETURN_URL### and ###PAGE_ID### replacement
                $tempTypolinkLinkAccessRestrictedPages = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'];
                unset($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']);
            }
            $LD = $this->menuTypoLink($this->menuArr[$key],$mainTarget,'','',$overrideArray, $addParams, $typeOverride, $showAccessRestrictedPages);
            $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] = $tempTypolinkLinkAccessRestrictedPages;
        }

Line 1620:

    /**
     * Calls typolink to create menu item links.
     *
     * @param    array        $page    Page record (uid points where to link to)
     * @param    string        $oTarget    Target frame/window
     * @param    boolean        $no_cache    TRUE if caching should be disabled
     * @param    string        $script    Alternative script name
     * @param    array        $overrideArray    Array to override values in $page
     * @param    string        $addParams    Parameters to add to URL
     * @param    array        $typeOverride    "type" value
     * @param    boolean        $enableRestrictedPages    Enable link generation for restricted pages
     * @return    array        See linkData
     */
    function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '', $enableRestrictedPages = false) {
        $conf = array(
            'parameter' => is_array($overrideArray) && $overrideArray['uid'] ? $overrideArray['uid'] : $page['uid'],
        );
        if ($typeOverride && t3lib_utility_Math::canBeInterpretedAsInteger($typeOverride)) {
            $conf['parameter'] .= ',' . $typeOverride;
        }
        if ($addParams) {
            $conf['additionalParams'] = $addParams;
        }
        if ($no_cache) {
            $conf['no_cache'] = TRUE;
        }
        if ($oTarget) {
            $conf['target'] = $oTarget;
        }
        if ($page['sectionIndex_uid']) {
            $conf['section'] = $page['sectionIndex_uid'];
        }
        if ($enableRestrictedPages) {
            $conf['linkAccessRestrictedPages'] = TRUE;
        }

        $this->parent_cObj->typoLink('|', $conf);
        $LD = $this->parent_cObj->lastTypoLinkLD;

        $LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
        return $LD;
    }

Actions #4

Updated by Riccardo De Contardi almost 9 years ago

  • Description updated (diff)
  • Category deleted (Communication)
  • TYPO3 Version set to 4.5
  • Is Regression set to No

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions #5

Updated by Riccardo De Contardi almost 9 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF