From d0688686669d344d8d0a4c87d55611eff4b74d4d Mon Sep 17 00:00:00 2001
From: Tomasz Narloch
Date: Wed, 3 Jan 2018 01:14:24 +0100
Subject: [PATCH] Do not add default or active Itemid to every link without own
menu item (#19099)
* Do not add default or active Itemid to every link without own menu item
* Allow to login when there is no menu item for login page and home page is restricted
* Correctly redirect user to preferred site language association
* Fix link for com_users login form
---
.../src/Component/Router/Rules/MenuRules.php | 20 +++----
libraries/src/Router/SiteRouter.php | 18 +-----
modules/mod_login/tmpl/default.php | 4 +-
.../system/languagefilter/languagefilter.php | 55 +++++++++++--------
templates/beez3/html/mod_login/default.php | 4 +-
templates/protostar/offline.php | 4 +-
templates/system/offline.php | 4 +-
.../rules/JComponentRouterRulesMenuTest.php | 8 +--
.../libraries/cms/router/JRouterSiteTest.php | 18 ------
9 files changed, 50 insertions(+), 85 deletions(-)
diff --git a/libraries/src/Component/Router/Rules/MenuRules.php b/libraries/src/Component/Router/Rules/MenuRules.php
index 973d01095c252..467074704f72d 100644
--- a/libraries/src/Component/Router/Rules/MenuRules.php
+++ b/libraries/src/Component/Router/Rules/MenuRules.php
@@ -156,20 +156,16 @@ public function preprocess(&$query)
}
}
- // Check if the active menuitem matches the requested language
- if ($active && $active->component === 'com_' . $this->router->getName()
- && ($language === '*' || in_array($active->language, array('*', $language)) || !\JLanguageMultilang::isEnabled()))
+ // If there is no view and task in query then add the default item id
+ if (!isset($query['view']) && !isset($query['task']))
{
- $query['Itemid'] = $active->id;
- return;
- }
-
- // If not found, return language specific home link
- $default = $this->router->menu->getDefault($language);
+ // If not found, return language specific home link
+ $default = $this->router->menu->getDefault($language);
- if (!empty($default->id))
- {
- $query['Itemid'] = $default->id;
+ if (!empty($default->id))
+ {
+ $query['Itemid'] = $default->id;
+ }
}
}
diff --git a/libraries/src/Router/SiteRouter.php b/libraries/src/Router/SiteRouter.php
index 3653222cf0006..b9845fa92e253 100644
--- a/libraries/src/Router/SiteRouter.php
+++ b/libraries/src/Router/SiteRouter.php
@@ -707,26 +707,14 @@ protected function createUri($url)
if ($itemid === null)
{
- if ($option = $uri->getVar('option'))
+ if (!$uri->getVar('option'))
{
- $item = $this->menu->getItem($this->getVar('Itemid'));
+ $option = $this->getVar('option');
- if ($item !== null && $item->component === $option)
- {
- $uri->setVar('Itemid', $item->id);
- }
- }
- else
- {
- if ($option = $this->getVar('option'))
+ if ($option)
{
$uri->setVar('option', $option);
}
-
- if ($itemid = $this->getVar('Itemid'))
- {
- $uri->setVar('Itemid', $itemid);
- }
}
}
else
diff --git a/modules/mod_login/tmpl/default.php b/modules/mod_login/tmpl/default.php
index fcd3b1c962c94..5ea82c8cbc019 100644
--- a/modules/mod_login/tmpl/default.php
+++ b/modules/mod_login/tmpl/default.php
@@ -15,7 +15,7 @@
JHtml::_('bootstrap.tooltip');
?>
-
-