Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilingual: Correcting login redirect #12932

Merged
merged 6 commits into from
Nov 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 20 additions & 12 deletions plugins/system/languagefilter/languagefilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,24 +615,27 @@ public function onUserLogin($user, $options = array())

$foundAssociation = false;

if ($active)
/**
* Looking for associations.
* If the login menu item form contains an internal URL redirection,
* This will override the automatic change to the user preferred site language.
* In that case we use the redirect as defined in the menu item.
* Otherwise we redirect, when available, to the user preferred site language.
*/
if ($active && !$active->params['login_redirect_url'])
{
if ($assoc)
{
$associations = MenusHelper::getAssociations($active->id);
}

// The login menu item contains a redirection.
// This will override the automatic change to the user preferred language
if ($active->params['login_redirect_url'])
{
$this->app->setUserState('users.login.form.return', JRoute::_($this->app->getUserState('users.login.form.return'), false));
}
elseif ($this->app->getUserState('users.login.form.return'))
{
// The login module contains a menu item redirection. Try to get association from that menu item.
$itemid = preg_replace('/\D+/', '', $this->app->getUserState('users.login.form.return'));
// Retrieves the Itemid from a login form.
$uri = new JUri($this->app->getUserState('users.login.form.return'));

if ($uri->getVar('Itemid'))
{
// The login form contains a menu item redirection. Try to get associations from that menu item.
// If any association set to the user preferred site language, redirect to that page.
if ($assoc)
{
$associations = MenusHelper::getAssociations($itemid);
Expand All @@ -647,13 +650,18 @@ public function onUserLogin($user, $options = array())
}
elseif (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code]))
{
/**
* The login form does not contain a menu item redirection.
* The active menu item has associations.
* We redirect to the user preferred site language associated page.
*/
$associationItemid = $associations[$lang_code];
$this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $associationItemid);
$foundAssociation = true;
}
elseif ($active->home)
{
// We are on a Home page, we redirect to the user site language home page
// We are on a Home page, we redirect to the user preferred site language Home page.
$item = $menu->getDefault($lang_code);

if ($item && $item->language != $active->language && $item->language != '*')
Expand Down