Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions components/com_content/View/Article/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,13 @@ public function display($tpl = null)
{
if ($this->user->get('guest'))
{
$return = base64_encode(Uri::getInstance());
$login_url_with_return = Route::_('index.php?option=com_users&return=' . $return);
$uri = new Uri('index.php');
$uri->setQuery($app->getRouter()->getVars());

$login_url_with_return = new Uri(Route::_('index.php?option=com_users&view=login', false));
$login_url_with_return->setVar('return', base64_encode($uri->toString()));
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'notice');
$app->redirect($login_url_with_return, 403);
$app->redirect($login_url_with_return->toString(), 403);
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions components/com_content/tmpl/article/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@
<?php echo HTMLHelper::_('content.prepare', $this->item->introtext); ?>
<?php // Optional link to let them register to see the whole article. ?>
<?php if ($params->get('show_readmore') && $this->item->fulltext != null) : ?>
<?php $menu = Factory::getApplication()->getMenu(); ?>
<?php $active = $menu->getActive(); ?>
<?php $itemId = $active->id; ?>
<?php $link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); ?>
<?php $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); ?>
<?php $link = new Uri(Route::_('index.php?option=com_users&view=login', false)); ?>
<?php $uri = new Uri(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)); ?>
<?php $router = Factory::getApplication()->getRouter(); ?>
<?php $router->buildComponentPreprocess($router, $uri); ?>
<?php $link->setVar('return', base64_encode($uri->toString())); ?>
<p class="com-content-article__readmore readmore">
<a href="<?php echo $link; ?>" class="register">
<?php $attribs = json_decode($this->item->attribs); ?>
Expand Down
10 changes: 5 additions & 5 deletions components/com_content/tmpl/category/blog_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
if ($params->get('access-view')) :
$link = Route::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
else :
$menu = Factory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false));
$link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)));
$link = new Uri(Route::_('index.php?option=com_users&view=login', false));
$uri = new Uri(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
$router = Factory::getApplication()->getRouter();
$router->buildComponentPreprocess($router, $uri);
$link->setVar('return', base64_encode($uri->toString()));
endif; ?>

<?php echo LayoutHelper::render('joomla.content.readmore', array('item' => $this->item, 'params' => $params, 'link' => $link)); ?>
Expand Down
8 changes: 5 additions & 3 deletions components/com_content/tmpl/category/default_articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@
<?php else : ?>
<?php
echo $this->escape($article->title) . ' : ';
$itemId = Factory::getApplication()->getMenu()->getActive()->id;
$link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false));
$link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language)));
$link = new Uri(Route::_('index.php?option=com_users&view=login', false));
$uri = new Uri(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language));
$router = Factory::getApplication()->getRouter();
$router->buildComponentPreprocess($router, $uri);
$link->setVar('return', base64_encode($uri->toString()));
?>
<a href="<?php echo $link; ?>" class="register">
<?php echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE'); ?>
Expand Down
10 changes: 5 additions & 5 deletions components/com_content/tmpl/featured/default_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@
if ($params->get('access-view')) :
$link = Route::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
else :
$menu = Factory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link = new Uri(Route::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false));
$link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)));
$link = new Uri(Route::_('index.php?option=com_users&view=login', false));
$uri = new Uri(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
$router = Factory::getApplication()->getRouter();
$router->buildComponentPreprocess($router, $uri);
$link->setVar('return', base64_encode($uri->toString()));
endif; ?>

<?php echo LayoutHelper::render('joomla.content.readmore', array('item' => $this->item, 'params' => $params, 'link' => $link)); ?>
Expand Down
8 changes: 7 additions & 1 deletion components/com_users/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ public function login()
// Set the return URL if empty.
if (empty($data['return']))
{
$data['return'] = 'index.php?option=com_users&view=profile';
$uri = new Uri('index.php?option=com_users&view=profile');
$router = Factory::getApplication()->getRouter();

// Add Itemid to link
$router->buildComponentPreprocess($router, $uri);

$data['return'] = $uri->toString();
}

// Set the return URL in the user state to allow modification by plugins
Expand Down
3 changes: 2 additions & 1 deletion components/com_users/tmpl/login/default_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
<?php endif; ?>

<form action="<?php echo Route::_('index.php?option=com_users&task=user.login'); ?>" method="post" class="com-users-login__form form-validate form-horizontal well">
<form action="<?php echo Route::_('index.php?option=com_users&view=login'); ?>" method="post" class="com-users-login__form form-validate form-horizontal well">

<fieldset>
<?php foreach ($this->form->getFieldset('credentials') as $field) : ?>
Expand Down Expand Up @@ -95,6 +95,7 @@
</div>

<?php $return = $this->form->getValue('return', '', $this->params->get('login_redirect_url', $this->params->get('login_redirect_menuitem'))); ?>
<input type="hidden" name="task" value="user.login">
<input type="hidden" name="return" value="<?php echo base64_encode($return); ?>">
<?php echo HTMLHelper::_('form.token'); ?>
</fieldset>
Expand Down
3 changes: 2 additions & 1 deletion components/com_users/tmpl/login/default_logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</div>
<?php endif; ?>

<form action="<?php echo Route::_('index.php?option=com_users&task=user.logout'); ?>" method="post" class="com-users-logout__form form-horizontal well">
<form action="<?php echo Route::_('index.php?option=com_users&view=login'); ?>" method="post" class="com-users-logout__form form-horizontal well">
<div class="com-users-logout__submit control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">
Expand All @@ -48,6 +48,7 @@
</button>
</div>
</div>
<input type="hidden" name="task" value="user.logout">
<?php if ($this->params->get('logout_redirect_url')) : ?>
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>">
<?php else : ?>
Expand Down
2 changes: 1 addition & 1 deletion components/com_users/tmpl/profile/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<?php if (Factory::getUser()->id == $this->data->id) : ?>
<ul class="com-users-profile__edit btn-toolbar float-right">
<li class="btn-group">
<a class="btn" href="<?php echo Route::_('index.php?option=com_users&task=profile.edit&user_id=' . (int) $this->data->id); ?>">
<a class="btn" href="<?php echo Route::_('index.php?option=com_users&view=profile&task=profile.edit&user_id=' . (int) $this->data->id); ?>">
<span class="icon-user"></span> <?php echo Text::_('COM_USERS_EDIT_PROFILE'); ?>
</a>
</li>
Expand Down
6 changes: 5 additions & 1 deletion layouts/joomla/edit/frontediting_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
$position = $displayData['position'];
$menusEditing = $displayData['menusediting'];
$parameters = ComponentHelper::getParams('com_modules');
$redirectUri = '&return=' . urlencode(base64_encode(Uri::getInstance()->toString()));

$uri = new Uri('index.php');
$uri->setQuery(Factory::getApplication()->getRouter()->getVars());

$redirectUri = '&return=' . urlencode(base64_encode($uri->toString()));
$target = '_blank';
$itemid = Factory::getApplication()->input->get('Itemid', '0', 'int');

Expand Down
10 changes: 8 additions & 2 deletions libraries/src/Application/SiteApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ protected function authorise($itemid)
{
if ($user->get('id') == 0)
{
$uri = new Uri('index.php');
$uri->setQuery($this->getRouter()->getVars());

// Set the data
$this->setUserState('users.login.form.data', array('return' => Uri::getInstance()->toString()));
$this->setUserState('users.login.form.data', array('return' => $uri->toString()));

$url = Route::_('index.php?option=com_users&view=login', false);

Expand Down Expand Up @@ -745,7 +748,10 @@ protected function render()

if ($this->get('offline') && !Factory::getUser()->authorise('core.login.offline'))
{
$this->setUserState('users.login.form.data', array('return' => Uri::getInstance()->toString()));
$uri = new Uri('index.php');
$uri->setQuery($this->getRouter()->getVars());

$this->setUserState('users.login.form.data', array('return' => $uri->toString()));
$this->set('themeFile', 'offline.php');
$this->setHeader('Status', '503 Service Temporarily Unavailable', 'true');
}
Expand Down
21 changes: 8 additions & 13 deletions libraries/src/Component/Router/Rules/MenuRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,15 @@ 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)) || !Multilanguage::isEnabled()))
// If there is no view in the query then use the active item id
if (!isset($query['view']))
{
$query['Itemid'] = $active->id;
return;
}

// If not found, return language specific home link
$default = $this->router->menu->getDefault($language);

if (!empty($default->id))
{
$query['Itemid'] = $default->id;
// Check if the active menuitem matches the requested language
if ($active !== null && $active->component === 'com_' . $this->router->getName()
&& ($language === '*' || in_array($active->language, array('*', $language)) || !Multilanguage::isEnabled()))
{
$query['Itemid'] = $active->id;
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion libraries/src/Router/SiteRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,14 @@ public function parseRawRoute(&$router, &$uri)
{
$item = $this->menu->getItem($uri->getVar('Itemid'));
}
else
elseif (!$uri->getVar('option'))
{
$item = $this->menu->getDefault($this->app->getLanguage()->getTag());
}
else
{
$item = null;
}

if ($item && $item->type === 'alias')
{
Expand Down
14 changes: 8 additions & 6 deletions modules/mod_login/Helper/LoginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class LoginHelper
*/
public static function getReturnUrl($params, $type)
{
$item = Factory::getApplication()->getMenu()->getItem($params->get($type));

// Stay on the same page
$url = Uri::getInstance()->toString();
$app = Factory::getApplication();
$item = $app->getMenu()->getItem($params->get($type));

if ($item)
{
Expand All @@ -46,10 +44,14 @@ public static function getReturnUrl($params, $type)
$lang = '&lang=' . $item->language;
}

$url = 'index.php?Itemid=' . $item->id . $lang;
return base64_encode('index.php?Itemid=' . $item->id . $lang);
}

return base64_encode($url);
// Stay on the same page
$uri = new Uri('index.php');
$uri->setQuery($app->getRouter()->getVars());

return base64_encode($uri->toString());
}

/**
Expand Down
3 changes: 1 addition & 2 deletions modules/mod_login/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Text::script('JSHOW');
Text::script('JHIDE');
?>
<form id="login-form" class="mod-login" action="<?php echo Route::_('index.php', true); ?>" method="post">
<form id="login-form" class="mod-login" action="<?php echo Route::_('index.php?option=com_users&view=login'); ?>" method="post">

<?php if ($params->get('pretext')) : ?>
<div class="mod-login__pretext pretext">
Expand Down Expand Up @@ -117,7 +117,6 @@
<?php echo Text::_('MOD_LOGIN_FORGOT_YOUR_PASSWORD'); ?></a>
</li>
</ul>
<input type="hidden" name="option" value="com_users">
<input type="hidden" name="task" value="user.login">
<input type="hidden" name="return" value="<?php echo $return; ?>">
<?php echo HTMLHelper::_('form.token'); ?>
Expand Down
Loading