Skip to content

Commit

Permalink
[joomla#27959] *Wrong redirection when login on multilang site with S…
Browse files Browse the repository at this point in the history
…EF on.
  • Loading branch information
infograf768 authored and chdemko committed Mar 9, 2012
1 parent 421d65b commit cb122dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions installation/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $ -> Language fix or change

09-Mar-2012 Christophe Demko
# [#27052] *content menu displayed when disable component content
# [#27959] *Wrong redirection when login on multilang site with SEF on. (Jean-Marie Simonet)

07-Mar-2012 Christophe Demko
# [#27951] Missing parameter handling in magic proxy methods for name quotes (Sven Hurt)
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_languages/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function getList(&$params)
unset($languages[$i]);
}
// Do not display language without authorized access level
elseif ($language->access && !in_array($language->access, $levels)) {
elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
unset($languages[$i]);
}
else {
Expand Down
26 changes: 23 additions & 3 deletions plugins/system/languagefilter/languagefilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// no direct access
defined('_JEXEC') or die;

JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
/**
* Joomla! Language Filter Plugin
*
Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct(&$subject, $config)
$levels = $user->getAuthorisedViewLevels();
foreach (self::$sefs as $sef => &$language)
{
if ($language->access && !in_array($language->access, $levels))
if (isset($language->access) && $language->access && !in_array($language->access, $levels))
{
unset(self::$sefs[$sef]);
}
Expand Down Expand Up @@ -372,8 +372,17 @@ public function onUserAfterSave($user, $isnew, $success, $msg)
public function onUserLogin($user, $options = array())
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($app->isSite() && $this->params->get('automatic_change', 1))
{
// Load associations
if ($app->get('menu_associations', 0)) {
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
}

$lang_code = $user['language'];
if (empty($lang_code))
{
Expand All @@ -390,8 +399,19 @@ public function onUserLogin($user, $options = array())
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);

// Change the language code
JFactory::getLanguage()->setLanguage($lang_code);

// Change the redirect (language have changed)
$app->setUserState('users.login.form.return', 'index.php?option=com_users&view=profile');
if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
$itemid = $associations[$lang_code];
$app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid);
}
else
{
$itemid = isset($homes[$lang_code]) ? $homes[$lang_code]->id : $homes['*']->id;
$app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid);
}
}
}
}
Expand Down

0 comments on commit cb122dd

Please sign in to comment.