diff --git a/components/com_content/View/Article/HtmlView.php b/components/com_content/View/Article/HtmlView.php index de3e568cea3cc..414e96e358cd1 100644 --- a/components/com_content/View/Article/HtmlView.php +++ b/components/com_content/View/Article/HtmlView.php @@ -197,10 +197,13 @@ public function display($tpl = null) { if ($this->user->get('guest')) { - $return = base64_encode(Uri::getInstance()); - $login_url_with_return = Route::_('index.php?option=com_users&return=' . $return); + $uri = new Uri('index.php'); + $uri->setQuery($app->getRouter()->getVars()); + + $login_url_with_return = new Uri(Route::_('index.php?option=com_users&view=login', false)); + $login_url_with_return->setVar('return', base64_encode($uri->toString())); $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'notice'); - $app->redirect($login_url_with_return, 403); + $app->redirect($login_url_with_return->toString(), 403); } else { diff --git a/components/com_content/tmpl/article/default.php b/components/com_content/tmpl/article/default.php index 8cc0ae56fb56a..38841ee42e27e 100644 --- a/components/com_content/tmpl/article/default.php +++ b/components/com_content/tmpl/article/default.php @@ -141,11 +141,11 @@ item->introtext); ?> get('show_readmore') && $this->item->fulltext != null) : ?> - getMenu(); ?> - getActive(); ?> - id; ?> - - setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); ?> + + item->slug, $this->item->catid, $this->item->language)); ?> + getRouter(); ?> + buildComponentPreprocess($router, $uri); ?> + setVar('return', base64_encode($uri->toString())); ?>
item->attribs); ?> diff --git a/components/com_content/tmpl/category/blog_item.php b/components/com_content/tmpl/category/blog_item.php index 83406ea7adf96..fad79e5ed7d3c 100644 --- a/components/com_content/tmpl/category/blog_item.php +++ b/components/com_content/tmpl/category/blog_item.php @@ -72,11 +72,11 @@ if ($params->get('access-view')) : $link = Route::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); else : - $menu = Factory::getApplication()->getMenu(); - $active = $menu->getActive(); - $itemId = $active->id; - $link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); - $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); + $link = new Uri(Route::_('index.php?option=com_users&view=login', false)); + $uri = new Uri(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); + $router = Factory::getApplication()->getRouter(); + $router->buildComponentPreprocess($router, $uri); + $link->setVar('return', base64_encode($uri->toString())); endif; ?> $this->item, 'params' => $params, 'link' => $link)); ?> diff --git a/components/com_content/tmpl/category/default_articles.php b/components/com_content/tmpl/category/default_articles.php index f5812d4006841..4253eaeca47c6 100644 --- a/components/com_content/tmpl/category/default_articles.php +++ b/components/com_content/tmpl/category/default_articles.php @@ -176,9 +176,11 @@ escape($article->title) . ' : '; - $itemId = Factory::getApplication()->getMenu()->getActive()->id; - $link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); - $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language))); + $link = new Uri(Route::_('index.php?option=com_users&view=login', false)); + $uri = new Uri(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language)); + $router = Factory::getApplication()->getRouter(); + $router->buildComponentPreprocess($router, $uri); + $link->setVar('return', base64_encode($uri->toString())); ?> diff --git a/components/com_content/tmpl/featured/default_item.php b/components/com_content/tmpl/featured/default_item.php index a5e6e2212f3fe..d6f22b738d2d5 100644 --- a/components/com_content/tmpl/featured/default_item.php +++ b/components/com_content/tmpl/featured/default_item.php @@ -92,11 +92,11 @@ if ($params->get('access-view')) : $link = Route::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); else : - $menu = Factory::getApplication()->getMenu(); - $active = $menu->getActive(); - $itemId = $active->id; - $link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); - $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); + $link = new Uri(Route::_('index.php?option=com_users&view=login', false)); + $uri = new Uri(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); + $router = Factory::getApplication()->getRouter(); + $router->buildComponentPreprocess($router, $uri); + $link->setVar('return', base64_encode($uri->toString())); endif; ?> $this->item, 'params' => $params, 'link' => $link)); ?> diff --git a/components/com_users/Controller/UserController.php b/components/com_users/Controller/UserController.php index 643a92f61d39f..45f2c6d2cb52d 100644 --- a/components/com_users/Controller/UserController.php +++ b/components/com_users/Controller/UserController.php @@ -101,7 +101,13 @@ public function login() // Set the return URL if empty. if (empty($data['return'])) { - $data['return'] = 'index.php?option=com_users&view=profile'; + $uri = new Uri('index.php?option=com_users&view=profile'); + $router = Factory::getApplication()->getRouter(); + + // Add Itemid to link + $router->buildComponentPreprocess($router, $uri); + + $data['return'] = $uri->toString(); } // Set the return URL in the user state to allow modification by plugins diff --git a/components/com_users/tmpl/login/default_login.php b/components/com_users/tmpl/login/default_login.php index c63b7ea8d76c7..1dfc193cab4fb 100644 --- a/components/com_users/tmpl/login/default_login.php +++ b/components/com_users/tmpl/login/default_login.php @@ -46,7 +46,7 @@ -