diff --git a/modules/mod_login/helper.php b/modules/mod_login/helper.php index 1ef72956ad086..261b20389f3ce 100644 --- a/modules/mod_login/helper.php +++ b/modules/mod_login/helper.php @@ -30,69 +30,19 @@ class ModLoginHelper public static function getReturnURL($params, $type) { $app = JFactory::getApplication(); - $router = $app::getRouter(); - $url = null; + $item = $app->getMenu()->getItem($params->get($type)); - if ($itemid = $params->get($type)) + if ($item) { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('link')) - ->from($db->quoteName('#__menu')) - ->where($db->quoteName('published') . '=1') - ->where($db->quoteName('id') . '=' . $db->quote($itemid)); - - $db->setQuery($query); - - if ($link = $db->loadResult()) - { - if ($router->getMode() == JROUTER_MODE_SEF) - { - $url = 'index.php?Itemid=' . $itemid; - } - else - { - $url = $link . '&Itemid=' . $itemid; - } - } + $vars = $item->query; } - - if (!$url) + else { // Stay on the same page - $vars = $router->getVars(); - unset($vars['lang']); - - if ($router->getMode() == JROUTER_MODE_SEF) - { - if (isset($vars['Itemid'])) - { - $itemid = $vars['Itemid']; - $menu = $app->getMenu(); - $item = $menu->getItem($itemid); - unset($vars['Itemid']); - - if (isset($item) && $vars == $item->query) - { - $url = 'index.php?Itemid=' . $itemid; - } - else - { - $url = 'index.php?' . JUri::buildQuery($vars) . '&Itemid=' . $itemid; - } - } - else - { - $url = 'index.php?' . JUri::buildQuery($vars); - } - } - else - { - $url = 'index.php?' . JUri::buildQuery($vars); - } + $vars = $app::getRouter()->getVars(); } - return base64_encode($url); + return base64_encode('index.php?' . JUri::buildQuery($vars)); } /**