Added parameter 'isACP'
authorAlexander Ebert <ebert@woltlab.com>
Mon, 17 Dec 2012 15:56:39 +0000 (16:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 17 Dec 2012 15:56:39 +0000 (16:56 +0100)
Fixes #978

wcfsetup/install/files/lib/system/request/LinkHandler.class.php

index 7d23ba665790f8e379ee075685b1d63c39b76c75..92aa513ff0e20bef280d2f66c164e786109a1115 100644 (file)
@@ -26,6 +26,7 @@ class LinkHandler extends SingletonFactory {
        public function getLink($controller = null, array $parameters = array(), $url = '') {
                $abbreviation = 'wcf';
                $anchor = '';
+               $isACP = $originIsACP = RequestHandler::getInstance()->isACPRequest();
                $isRaw = false;
                $appendSession = true;
                if (isset($parameters['application'])) {
@@ -40,6 +41,15 @@ class LinkHandler extends SingletonFactory {
                        $appendSession = $parameters['appendSession'];
                        unset($parameters['appendSession']);
                }
+               if (isset($parameters['isACP'])) {
+                       $isACP = (bool) $parameters['isACP'];
+                       unset($parameters['isACP']);
+                       
+                       // drop session id if link leads to ACP from frontend or vice versa
+                       if ($originIsACP != $isACP) {
+                               $appendSession = false;
+                       }
+               }
                
                // remove anchor before parsing
                if (($pos = strpos($url, '#')) !== false) {
@@ -83,7 +93,7 @@ class LinkHandler extends SingletonFactory {
                
                // handle applications
                if (!PACKAGE_ID) {
-                       $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . (RequestHandler::getInstance()->isACPRequest() ? 'acp/' : '') . $url;
+                       $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url;
                }
                else {
                        // try to resolve abbreviation
@@ -97,7 +107,7 @@ class LinkHandler extends SingletonFactory {
                                $application = ApplicationHandler::getInstance()->getPrimaryApplication();
                        }
                        
-                       $url = $application->getPageURL() . (RequestHandler::getInstance()->isACPRequest() ? 'acp/' : '') . $url;
+                       $url = $application->getPageURL() . ($isACP ? 'acp/' : '') . $url;
                }
                
                // append previously removed anchor