Skip to content

Commit

Permalink
Optimizing mod_login helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar committed Feb 9, 2015
1 parent 6dd2194 commit 7e61dad
Showing 1 changed file with 5 additions and 54 deletions.
59 changes: 5 additions & 54 deletions modules/mod_login/helper.php
Expand Up @@ -31,68 +31,19 @@ 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);
}
}

return base64_encode($url);
return base64_encode('index.php?' . JUri::buildQuery($vars));
}

/**
Expand Down

0 comments on commit 7e61dad

Please sign in to comment.